Difference between revisions of "Area 51"

From Mudlet
Jump to navigation Jump to search
(→‎setMovie PR #5827: make the gif go away on click, so it doesn't become frustrating)
Line 1,340: Line 1,340:
 
     createLabel("kymip", 300, 300, width, height, 0)
 
     createLabel("kymip", 300, 300, width, height, 0)
 
     setMovie("kymip", saveto)
 
     setMovie("kymip", saveto)
 +
    setLabelReleaseCallback("kymip", function() deleteLabel("kymip") end)
 
   end, true)
 
   end, true)
  

Revision as of 20:06, 18 January 2022

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.

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.

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


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.

getCharacterName, PR #3952 open

getCharacterName()
Returns the name entered into the "Character name" field on the Connection Preferences form. Can be used to find out the name that might need to be handled specially in scripts or anything that needs to be personalized to the player. If there is nothing set in that entry will return an empty string.

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

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

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

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

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

loadMusicFile, PR #5799 merged

loadMusicFile(settings table)
Loads music files from the Internet or the local file system to the "media" folder of the profile for later use with playMusicFile() and stopMusic(). Although files could be loaded directly at playing time from playMusicFile(), loadMusicFile() provides the advantage of loading files in advance.
Required Key Value Purpose
Yes name <file name>
  • Name of the media file.
  • May contain directory information (i.e. weather/lightning.wav).
  • May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
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(), playMusicFile(), playSoundFile(), stopMusic(), stopSounds(), purgeMediaCache(), Mud Client Media Protocol

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

-- Download from the Internet
loadMusicFile({
    name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
})

-- OR download from the profile
loadMusicFile({name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"})

-- OR download from the local file system
loadMusicFile({name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"})
---- Ordered Parameter Syntax of loadMediaFile(name[, url]) ----

-- Download from the Internet
loadMusicFile(
    "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
)

-- OR download from the profile
loadMusicFile(getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3")

-- OR download from the local file system
loadMusicFile("C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3")

loadSoundFile, PR #5799 merged

loadSoundFile(settings table)
Loads sound files from the Internet or the local file system to the "media" folder of the profile for later use with playSoundFile() and stopSounds(). Although files could be loaded directly at playing time from playSoundFile(), loadSoundFile() provides the advantage of loading files in advance.
Required Key Value Purpose
Yes name <file name>
  • Name of the media file.
  • May contain directory information (i.e. weather/lightning.wav).
  • May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
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: loadMusicFile(), playMusicFile(), playSoundFile(), stopMusic(), stopSounds(), purgeMediaCache(), Mud Client Media Protocol

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

-- Download from the Internet
loadSoundFile({
    name = "cow.wav"
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
})

-- OR download from the profile
loadSoundFile({name = getMudletHomeDir().. "/cow.wav"})

-- OR download from the local file system
loadSoundFile({name = "C:/Users/Tamarindo/Documents/cow.wav"})
---- Ordered Parameter Syntax of loadSoundFile(name[,url]) ----

-- Download from the Internet
loadSoundFile("cow.wav", "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/")

-- OR download from the profile
loadSoundFile(getMudletHomeDir().. "/cow.wav")

-- OR download from the local file system
loadSoundFile("C:/Users/Tamarindo/Documents/cow.wav")

playMusicFile, PR #5799 merged

playMusicFile(settings table)
Plays music files from the Internet or the local file system to the "media" folder of the profile for later use with stopMusic().
Required Key Value Default Purpose
Yes name <file name>  
  • Name of the media file.
  • May contain directory information (i.e. weather/lightning.wav).
  • May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
  • Wildcards * and ? may be used within the name to randomize media files selection.
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 music files when true.
  • Restarts matching new music 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.

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

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

-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playMusicFile({
    name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
})

-- OR copy once from the game's profile, and play a music file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playMusicFile({
    name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"
    , volume = 75
})

-- OR copy once from the local file system, and play a music file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playMusicFile({
    name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"
    , volume = 75
})

-- OR download once from the Internet, and play music stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "rugby" for stopping this unique music later
---- [tag] reference of "ambience" to stop and music later with the same tag
---- [continue] playing this music if another request for the same music comes in (false restarts it) 
---- [url] to download once from the Internet if the music does not exist in the profile's media directory
playMusicFile({
    name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
    , volume = nil -- nil lines are optional, no need to use
    , fadein = 20000
    , fadein = 53000
    , start = 10000
    , loops = nil -- nil lines are optional, no need to use
    , key = "rugby"
    , tag = "ambience"
    , continue = true
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
})
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url]) ----

-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playMusicFile(
    "167124__patricia-mcmillen__rugby-club-in-spain.mp3"  -- name
)

-- OR copy once from the game's profile, and play a music file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playMusicFile(
    getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
    , 75 -- volume
)

-- OR copy once from the local file system, and play a music file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playMusicFile(
    "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
    , 75 -- volume
)

-- OR download once from the Internet, and play music stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "rugby" for stopping this unique music later
---- [tag] reference of "ambience" to stop and music later with the same tag
---- [continue] playing this music if another request for the same music comes in (false restarts it) 
---- [url] to download once from the Internet if the music does not exist in the profile's media directory
playMusicFile(
    "167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
    , nil -- volume
    , 20000 -- fadein
    , 53000 -- fadeout
    , 10000 -- start
    , nil -- loops
    , "rugby" -- key 
    , "ambience" -- tag
    , true -- continue
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url
)

playSoundFile, PR #5799 merged

playSoundFile(settings table)
Plays sound files from the Internet or the local file system to the "media" folder of the profile for later use with stopSounds().
Required Key Value Default Purpose
Yes name <file name>  
  • Name of the media file.
  • May contain directory information (i.e. weather/lightning.wav).
  • May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
  • Wildcards * and ? may be used within the name to randomize media files selection.
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 priority 1 to 100  
  • Halts the play of current or future played media files with a lower priority while this media plays.
Maybe url <url>  
  • Resource location where the media file may be downloaded.
  • Only required if the file is to be downloaded remotely.

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

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

-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playSoundFile({
    name = "cow.wav"
})

-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playSoundFile({
    name = getMudletHomeDir().. "/cow.wav"
    , volume = 75
})

-- OR copy once from the local file system, and play a sound file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playSoundFile({
    name = "C:/Users/Tamarindo/Documents/cow.wav"
    , volume = 75
})

-- OR download once from the Internet, and play a sound stored in the profile's media directory
---- [volume] of 75
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)
---- [key] reference of "cow" for stopping this unique sound later
---- [tag] reference of "animals" to stop a group of sounds later with the same tag
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory
playSoundFile({
    name = "cow.wav"
    , volume = 75
    , fadein = nil -- nil lines are optional, no need to use
    , fadeout = nil -- nil lines are optional, no need to use
    , start = nil -- nil lines are optional, no need to use
    , loops = 2
    , key = "cow"
    , tag = "animals"
    , priority = 25
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
})
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url]) ----

-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playSoundFile(
    "cow.wav" -- name
)

-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playSoundFile(
    getMudletHomeDir().. "/cow.wav" -- name
    , 75 -- volume
)

-- OR copy once from the local file system, and play a sound file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playSoundFile(
    "C:/Users/Tamarindo/Documents/cow.wav" -- name
    , 75 -- volume
)

-- OR download once from the Internet, and play a sound stored in the profile's media directory
---- [volume] of 75
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)
---- [key] reference of "cow" for stopping this unique sound later
---- [tag] reference of "animals" to stop a group of sounds later with the same tag
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory
playSoundFile(
    "cow.wav" -- name
    , 75 -- volume
    , nil -- fadein
    , nil -- fadeout
    , nil -- start
    , 2 -- loops
    , "cow" -- key 
    , "animals" -- tag
    , 25 -- priority
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url
)

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

stopMusic, PR #5799 merged

stopMusic(settings table)
Stop all music (no filter), or music that meets a combination of filters (name, key, and tag) intended to be paired with playMusicFile().
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: loadMusicFile(), loadSoundFile(), playMusicFile(), playSoundFile(), stopSounds(), purgeMediaCache(), Mud Client Media Protocol

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

-- Stop all playing music files for this profile associated with the API
stopMusic()

-- Stop playing the rugby mp3 by name
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})

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

-- Stop all playing music files for this profile associated with the API
stopMusic()

-- Stop playing the rugby mp3 by name
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")

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

stopSounds, PR #5799 merged

stopSounds(settings table)
Stop all sounds (no filter), or sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with playSoundFile().
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.
No priority 1 to 100
  • Halts the play of current or future played media files with a matching or lower priority.

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

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

-- Stop all playing sound files for this profile associated with the API
stopSounds()

-- Stop playing the cow sound
stopSounds({name = "cow.wav"})

-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50
---- This would not stop sounds tagged as "animals" greater than priority 50.  This is an "AND" and not an "OR".
stopSounds({
    name = nil -- nil lines are optional, no need to use
    , key = nil -- nil lines are optional, no need to use
    , tag = "animals"
    , priority = 50
})
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority]) ----

-- Stop all playing sound files for this profile associated with the API
stopSounds()

-- Stop playing the cow sound
stopSounds("cow.wav")

-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50
---- This would not stop sounds tagged as "animals" greater than priority 50.  This is an "AND" and not an "OR".
stopSounds(
    nil -- name
    , nil -- key
    , "animals" -- tag
    , 50 -- priority
)

Mudlet Object Functions

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

getProfileStats PR 5706

getProfileStats()
Returns a table with profile statistics for how many triggers, aliases, keys, timers, and scripts the profile has. Similar to the Statistics button in the script editor, accessible to Lua scripting.
Mudlet VersionAvailable in Mudlet4.15+
Example
-- show all stats
display(getProfileStats())

-- check how many active triggers there are
activetriggers = getProfileStats().triggers.active
cecho(f"<PaleGreen>We have <SlateGrey>{activetriggers}<PaleGreen> active triggers!\n")

Networking Functions

A collection of functions for managing networking.

String Functions

These functions are used to manipulate strings.

string.patternEscape, utf8.patternEscape PR 5806

escapedString = string.patternEscape(str) or escapedString = utf8.patternEscape(str)
Returns a version of str with all Lua pattern characters escaped to ensure string.match/find/etc look for the original str.
See also
string.trim(), string.genNocasePattern()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • str:
The string to escape lua pattern characters in.
Returns
  • The string with all special Lua pattern characters escaped.
Example
-- searching for a url inside of a string. 
local helpString = [[
This feature can be accessed by going to https://some-url.com/athing.html?param=value and
retrieving the result!
]]
local url = "https://some-url.com/"
display(helpString:find(url))
-- nil
display(helpString:find(string.patternEscape(url)))
-- 42
-- 62
display(url:patternEscape())
-- "https://some%-url%.com/"

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.

ansi2decho PR# 5670 merge, PR5719 merged

ansi2decho(text, default_colour)
Converts ANSI colour sequences in text to colour tags that can be processed by the decho() function.
See also: decho()
Mudlet VersionAvailable in Mudlet3.0+

Note Note: ANSI bold is available since Mudlet 3.7.1+.

Note Note: underline, italics, overline, and strikethrough supported since Mudlet 4.15+

Parameters
  • text:
String that contains ANSI colour sequences that should be replaced.
  • default_colour:
Optional - ANSI default colour code (used when handling orphan bold tags).
Return values
  • string text:
The decho-valid converted text.
  • string colour:
The ANSI code for the last used colour in the substitution (useful if you want to colour subsequent lines according to this colour).
Example
local replaced = ansi2decho('\27[0;1;36;40mYou say in a baritone voice, "Test."\27[0;37;40m')
-- 'replaced' should now contain <r><0,255,255:0,0,0>You say in a baritone voice, "Test."<r><192,192,192:0,0,0>
decho(replaced)

Or show a complete colourful squirrel! It's a lotta code to do all the colours, so click the Expand button on the right to show it:

decho(ansi2decho([[
                                                  �[38;5;95m▄�[48;5;95;38;5;130m▄▄▄�[38;5;95m█�[49m▀�[0m    �[0m
╭───────────────────────╮          �[38;5;95m▄▄�[0m          �[38;5;95m▄�[48;5;95;38;5;130m▄▄�[48;5;130m█�[38;5;137m▄�[48;5;137;38;5;95m▄�[49m▀�[0m      �[0m
│                       │         �[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95m▄�[49;38;5;95m▄▄▄�[48;5;95;38;5;137m▄▄▄�[49;38;5;95m▄▄�[48;5;95;38;5;130m▄�[48;5;130m███�[38;5;137m▄�[48;5;137m█�[48;5;95;38;5;95m█�[0m       �[0m
│  Encrypt everything!  │       �[38;5;95m▄�[48;5;187;38;5;16m▄�[48;5;16;38;5;187m▄�[38;5;16m█�[48;5;137;38;5;137m███�[38;5;187m▄�[38;5;16m▄▄�[38;5;137m██�[48;5;95;38;5;95m█�[48;5;130;38;5;130m█████�[48;5;137;38;5;137m██�[48;5;95;38;5;95m█�[0m       �[0m
│                       ├────  �[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;16m▄▄▄�[48;5;137m███�[48;5;16;38;5;16m█�[48;5;187m▄�[48;5;16m█�[48;5;137;38;5;137m█�[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[0m      �[0m
╰───────────────────────╯      �[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;16m▄�[38;5;16m█�[38;5;137m▄�[48;5;137m██████�[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95m▄�[49;38;5;95m▄�[0m    �[0m
                                �[38;5;95m▀�[48;5;137m▄�[38;5;137m███████�[38;5;95m▄�[49m▀�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95m▄�[49;38;5;95m▄�[0m   �[0m
                                  �[48;5;95;38;5;187m▄▄▄�[38;5;137m▄�[48;5;137m██�[48;5;95;38;5;95m█�[0m    �[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[48;5;137;38;5;137m███�[48;5;95m▄�[49;38;5;95m▄�[0m  �[0m
                                 �[38;5;187m▄�[48;5;187m███�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m   �[48;5;95;38;5;95m█�[48;5;130;38;5;130m█████████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[0m �[0m
                                �[38;5;187m▄�[48;5;187m███�[38;5;137m▄�[48;5;137m█�[48;5;95;38;5;95m█�[48;5;137;38;5;137m███�[48;5;95m▄�[49;38;5;95m▄�[0m  �[38;5;95m▀�[48;5;130m▄�[38;5;130m███████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                               �[48;5;95;38;5;95m█�[48;5;187;38;5;187m████�[48;5;137;38;5;137m██�[48;5;95m▄�[48;5;137;38;5;95m▄�[38;5;137m██�[38;5;95m▄�[38;5;137m█�[48;5;95m▄�[49;38;5;95m▄�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                              �[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;187;38;5;187m████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95m▄�[49;38;5;95m▄�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                           �[38;5;95m▄�[48;5;95m██�[48;5;137m▄▄�[48;5;187;38;5;187m████�[48;5;137;38;5;95m▄▄�[48;5;95;38;5;137m▄�[48;5;137m█�[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;137m████�[48;5;95;38;5;95m█�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
                                �[48;5;187;38;5;187m███�[48;5;95m▄�[38;5;137m▄▄▄▄�[48;5;137m██████�[48;5;95;38;5;95m█�[49m▄�[48;5;95;38;5;130m▄�[48;5;130m██████�[48;5;137;38;5;137m███�[38;5;95m▄�[49m▀�[0m�[0m
                                �[48;5;187;38;5;95m▄�[38;5;187m████�[48;5;137;38;5;137m█�[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;137m█████�[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[38;5;137m▄�[48;5;137m████�[48;5;95;38;5;95m█�[0m �[0m
                                �[48;5;95;38;5;95m█�[48;5;187;38;5;137m▄�[38;5;187m███�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██████�[48;5;95m▄▄�[48;5;130m▄▄▄▄▄�[48;5;137m██████�[48;5;95;38;5;95m█�[0m  �[0m
                              �[38;5;95m▄▄▄�[48;5;95;38;5;137m▄�[48;5;187m▄�[38;5;187m██�[48;5;95m▄�[48;5;137;38;5;95m▄�[38;5;137m█████�[38;5;95m▄�[38;5;137m███████████�[48;5;95;38;5;95m█�[0m   �[0m
                            �[38;5;95m▀▀▀▀▀▀▀▀�[48;5;187m▄▄▄�[48;5;95;38;5;137m▄�[48;5;137m██�[38;5;95m▄�[49m▀�[0m �[38;5;95m▀▀�[48;5;137m▄▄▄▄▄▄�[49m▀▀▀�[0m    �[0m
                                  �[38;5;95m▀▀▀▀▀▀▀▀▀�[0m                 �[0m
                                                                    ]]))

Squirrel-in-Mudlet.png

cecho PR #5669 merged, PR5719 merged, PR5751 merged

cecho([window], text)
Echoes text that can be easily formatted with colour, italics, bold, strikethrough, and underline tags. You can also include unicode art in it - try some examples from 1lineart.
See also: decho(), hecho(), creplaceLine()

Note Note: Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you cecho it will erase any previous echo sent to the label.

Parameters
  • window:
Optional - the window name to echo to - can either be none or "main" for the main window, or a miniconsole, userwindow, or label name.
  • text:
The text to display, with color names inside angle brackets <>, ie <red>. If you'd like to use a background color, put it after a colon : - <:red>. You can use the <reset> tag to reset to the default color. You can select any from this list: Color Table
Example
cecho("Hi! This text is <red>red, <blue>blue, <green> and green.")

cecho("<:green>Green background on normal foreground. Here we add an <ivory>ivory foreground.")

cecho("<blue:yellow>Blue on yellow text!")

cecho("\n<red>Red text with <i>italics</i>, <u>underline</u>, <s>strikethrough</s>, <o>overline</o>, and <b>bold</b>.")

cecho("\n<green><o><u>Green text with over and underline at the same time.</o></u>")

-- \n adds a new line
cecho("<red>one line\n<green>another line\n<blue>last line")

cecho("myinfo", "<green>All of this text is green in the myinfo miniconsole.")

cecho("<green>(╯°□°)<dark_green>╯︵ ┻━┻")

cecho("°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸")

cecho([[
 ██╗    ██╗     ██╗███╗   ██╗███████╗     █████╗ ██████╗ ████████╗
███║    ██║     ██║████╗  ██║██╔════╝    ██╔══██╗██╔══██╗╚══██╔══╝
╚██║    ██║     ██║██╔██╗ ██║█████╗      ███████║██████╔╝   ██║
 ██║    ██║     ██║██║╚██╗██║██╔══╝      ██╔══██║██╔══██╗   ██║
 ██║    ███████╗██║██║ ╚████║███████╗    ██║  ██║██║  ██║   ██║
 ╚═╝    ╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝    ╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝
]])

cecho2ansi PR# 5672 merged

ansiFormattedString = cecho2ansi(text)
Converts cecho formatted text to ansi formatted text. Used by cfeedTriggers, but useful if you want ansi formatted text for any other reason.
See also
cecho(), cfeedTriggers()
Mudlet VersionAvailable in Mudlet4.15+

Note Note: This function uses the ansi short colors (0-15) for color names which have base 16 ansi equivalents, such as 'red', 'blue', "lightBlue", "cyan", etc rather than the values defined in the color_table. If there is no base ansi equivalent then it will use the rgb values from the color_table for the color.

Parameters
  • text:
The cecho formatted text for conversion
Returns
  • String converted to ansi formatting
Example
-- replicates the functionality of cfeedTriggers() for a single line.
-- you would most likely just use cfeedTriggers, but it makes for a tidy example.
feedTriggers(cecho2ansi("\n<red>This is red.<reset> <i>italic</i>, <b>bold</b>, <s>strikethrough</s>, <u>underline</u>\n"))
Additional development notes

createScrollBox PR #5739

createScrollBox([name of parent window], name, x, y, width, height)
creates a graphical elements able to hold other graphical elements such as labels, miniconsoles, command lines etc. in it.

If the added elements don't fit into the ScrollBox scrollbars appear and allow scrolling.

Returns true or false.
See also: createLabel(), hideWindow(), showWindow(), resizeWindow(), moveWindow(), setWindow()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • name of parent window:
(Optional) name of the parent window the scrollBox is created in. Defaults to the main window if not provided.
  • name:
The name of the scrollBox. Must be unique. Passed as a string.
  • x, y, width, height
Parameters to set set the window size and location
Example
-- create a ScrollBox with the name sBox
createScrollBox("SBox",0,0,300,200)

-- create 3 Labels and put them into the ScrollBox
createLabel("SBox","SBoxLabel",0,0,200,200,1)
createLabel("SBox","SBoxLabel2",200,0,200,200,1)
createLabel("SBox","SBoxLabel3",400,0,200,200,1)

-- put some text on the labels
echo("SBoxLabel","Label")
echo("SBoxLabel2","Label2")
echo("SBoxLabel3","Label3")

-- change the colours of the labels to make it easier to distinguish them
setBackgroundColor("SBoxLabel",255,0,0)
setBackgroundColor("SBoxLabel2",0,255,0)
setBackgroundColor("SBoxLabel3",0,0,255)

decho PR #5669 merged PR5719 merged PR5751 merged

decho ([name of console,] text)
Color changes can be made using the format <FR,FG,FB:BR,BG,BB,[BA]> where each field is a number from 0 to 255. The background portion can be omitted using <FR,FG,FB> or the foreground portion can be omitted using <:BR,BG,BB,[BA]>. Arguments 2 and 3 set the default fore and background colors for the string using the same format as is used within the string, sans angle brackets, e.g. decho("<50,50,0:0,255,0>test").
You can also include <i>italics</i>, <b>bold</b>, <s>strikethrough</s>, <o>overline</o>, and <u>underline</u> tags.

Note Note: Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you decho it will erase any previous echo sent to the label.

See also: cecho(), hecho(), copy2decho()
Parameters
  • name of console
(Optional) Name of the console to echo to. If no name is given, this will defaults to the main window.
  • text:
The text that you’d like to echo with embedded color tags. Tags take the RGB values only, see below for an explanation.


Note Note: Optional background transparancy parameter (BA) available in Mudlet 4.10+

Example
decho("<50,50,0:0,255,0>test")

decho("miniconsolename", "<50,50,0:0,255,0>test")

decho("\n<255,0,0>Red text with <i>italics</i>, <u>underline</u>, <s>strikethrough</s>, and <b>bold</b> formatting.")

decho("<\n<0,128,0><o><u>Green text with both over and underlines.</u></o>")

decho2ansi PR# 5671 merged

ansiFormattedString = decho2ansi(text)
Converts decho formatted text to ansi formatted text. Used by dfeedTriggers, but useful if you want ansi formatted text for any other reason.
See also
decho(), dfeedTriggers()
Mudlet VersionAvailable in Mudlet4.10++

Note Note: non-color formatting added in Mudlet 4.15+

Parameters
  • text:
The decho formatted text for conversion
Returns
  • String converted to ansi formatting
Example
-- replicates the functionality of dfeedTriggers() for a single line.
-- you would most likely just use dfeedTriggers, but it makes for a tidy example.
feedTriggers(decho2ansi("\n<128,0,0>This is red.<r> <i>italic</i>, <b>bold</b>, <s>strikethrough</s>, <u>underline</u>\n"))

getHTMLformat PR#5751 merged

spanTag = getHTMLformat(formatTable)
Takes in a table of formatting options in the same style as getTextFormat() and returns a span tag which will format text after it as the table describes.
See also
getTextFormat(), getLabelFormat()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • formatTable:
Table with formatting options configured. Keys are foreground, background, bold, underline, overline, strikeout, italic, and reverse. All except for foreground and background should be boolean (true/false) values. Foreground and background are either { r, g, b, a } tables, or strings with QSS formatting directives
Returns
  • A string with the html span tag to format text in accordance with the format table.
Example
-- Returns a span tag for bold, red text on a green background
local span = getHTMLformat({
  foreground = { 255, 0, 0 },
  background = "#00FF00",
  bold = true
})

-- span will be '<span style="color: rgb(255, 0, 0);background-color: #00FF00; font-weight: bold; font-style: normal; text-decoration: none;">'

getLabelFormat PR#5751 merged

formatTable = getLabelFormat(labelName)
Returns a format table like the one returned by getTextFormat and suitable for getHTMLspan which will format text the same way as simply doing an echo to the label would
See also
getTextFormat(), getHTMLspan()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • labelName:
The name of the label to scan the format of
Returns
  • A table with all the formatting options to achieve a default text format for label labelName.
Example
-- creates a test label, sets a stylesheet, and then returns the default format table for that label.
createLabel("testLabel", 10, 10, 300, 200, 1)
setLabelStyleSheet([[
  color: rgb(0,0,180);
  border-width: 1px;
  border-style: solid;
  border-color: gold;
  border-radius: 10px;
  font-size: 12.0pt;
  background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
]])
local fmt = getLabelFormat("testLabel"))

--[[
{
  background = "rgba(0, 0, 0, 0)", -- this is transparent
  bold = false,
  foreground = "rgb(0,0,180)",
  italic = false,
  overline = false,
  reverse = false,
  strikeout = false,
  underline = false
}
--]]


getLabelSizeHint PR#5815 merged

width, height = getLabelSizeHint(labelName)
Returns the suggested labelsize as width and height
See also
getTextFormat(), getHTMLspan()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • labelName:
The name of the label to get the suggested size from
Returns
  • suggested width and height (to fit text and/or an image on a label)
Example
-- text resizing example
-- create the label
createLabel("textLabel",400,400,300,300,1)
-- put some text on it
echo("textLabel", "This is my Test.\nAnother Test")
-- resizes the label to fit the text
resizeWindow("textLabel", getLabelSizeHint("textLabel"))

-- image resizing example
-- create the label
createLabel("imageLabel",400,400,300,300,1)
-- put some image on it
setBackgroundImage("imageLabel", getMudletHomeDir.."/myLabelImage.png")
-- resizes the label to fit the image
resizeWindow("imageLabel", getLabelSizeHint("imageLabel"))

hecho PR #5669 merged, PR5719 merged, PR5751 merged

hecho([windowName], text)
Echoes text that can be easily formatted with colour tags in the hexadecimal format. You can also use italics, bold, strikethrough, and underline tags.
See Also: decho(), cecho()

Note Note: Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you hecho it will erase any previous echo sent to the label.

Parameters
  • windowName:
(optional) name of the window to echo to. Can either be omitted or "main" for the main window, else specify the miniconsoles name.
  • text:
The text to display, with color changes made within the string using the format |cFRFGFB,BRBGBB or #FRFGFB,BRBGBB where FR is the foreground red value, FG is the foreground green value, FB is the foreground blue value, BR is the background red value, etc., BRBGBB is optional. |r or #r can be used within the string to reset the colors to default. Hexadecimal color codes can be found here: https://www.color-hex.com/

Note Note: Transparency for background in hex-format available in Mudlet 4.10+

Example
hecho("\n#ffffff White text!")
-- your text in white
hecho("\n#ca0004 Red text! And now reset #rit to the default color")
-- your text in red, then reset to default using #r
hecho("\n#ffffff,ca0004 White text with a red background!")
-- your text in white, against a red background
hecho("\n|c0000ff Blue text, this time using |c instead of #")
-- your text in blue, activated with |c vs #.
hecho("\n#ff0000Red text with #iitalics#/i, |uunderline|/u, #ooverline#/o, #sstrikethrough#/s, and #bbold#/b formatting.")
-- shows the various individual formatting options
hecho("\n#008000#o#uGreen text with both over and underlines.#/o#/u")

hecho2ansi PR# 5671 merged

ansiFormattedString = hecho2ansi(text)
Converts hecho formatted text to ansi formatted text. Used by hfeedTriggers, but useful if you want ansi formatted text for any other reason.
See also
hecho(), hfeedTriggers()
Mudlet VersionAvailable in Mudlet4.10++

Note Note: non-color formatting added in Mudlet 4.15+

Parameters
  • text:
The hecho formatted text for conversion
Returns
  • String converted to ansi formatting
Example
-- replicates the functionality of hfeedTriggers() for a single line.
-- you would most likely just use hfeedTriggers, but it makes for a tidy example.
feedTriggers(hecho2ansi("\n#800000This is red.#r #iitalic#/i, #bbold#/b, #sstrikethrough#/s, #uunderline#/u\n"))

setMovie PR #5827

setMovie(label name, path to gif)
adds a gif to the selected label and animates it
Returns true
See also: setMovieStart(), setMoviePaused(), setMovieFrame(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the label the gif will be animated on
  • path:
path of the gif file
Example
-- download & show a gif within mudlet
local saveto = getMudletHomeDir().."/kymip.gif"
-- animation credit to https://opengameart.org/content/kymiball-ii-third-prototype-scraps
local url = "https://opengameart.org/sites/default/files/kymip_0.gif"

if downloadHandler then killAnonymousEventHandler(downloadHandler) end
downloadHandler = registerAnonymousEventHandler("sysDownloadDone",
  function(_, filename)
    if filename ~= saveto then
      return true
    end
    
    local width, height = getImageSize(saveto)

    createLabel("kymip", 300, 300, width, height, 0)
    setMovie("kymip", saveto)
    setLabelReleaseCallback("kymip", function() deleteLabel("kymip") end)
  end, true)

downloadFile(saveto, url)
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")

setMovieStart PR #5827

setMovieStart(label name)
starts the gif animated if stop or paused
Returns true
See also: setMovie(), setMoviePaused(), setMovieFrame(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--stops the animation
setMoviePaused("myMovie")
--restart the animation
setMovieStart("myMovie")


setMoviePaused PR #5827

setMoviePaused(label name)
toggles pause/unpause of the gif animation on the label
Returns true
See also: setMovie(), setMovieStart(), setMovieFrame(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--stops the animation
setMoviePaused("myMovie")

setMovieFrame PR #5827

setMovieFrame(label name, frame nr)
jumps to the frame (frame nr)
Returns true if succesful and false if frame doesn't exist
See also: setMovie(), setMovieStart(), setMoviePaused(), setMovieSpeed()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
  • frame nr:
the gif animations frame nr to jump to
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--stops the animation
setMoviePaused("myMovie")
-- jumps to frame 12 of the animation
setMovieFrame("myMovie", 12)
--start the animation
setMovieStart("myMovie")


setMovieSpeed PR #5827

setMovieSpeed(label name, speed in percent)
sets the animation speed to speed (in percent)
Returns true
See also: setMovie(), setMovieStart(), setMoviePaused(), setMovieFrame()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • label name:
name of the gif label
  • speed in percent:
the gif animations speed in percent for example 50 for 50% speed
Example
-- create a label with the name myMovie
createLabel("myMovie",0,0,200,200,0)

-- puts the gif on the label and animates it
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
--accelerates the animation to a speed of 150%
setMovieSpeed("myMovie",150)

windowType PR# 5696 open

typeOfWindow = windowType(windowName)
Given the name of a window, will return if it's a label, miniconsole, userwindow or a commandline.
See also
createLabel(), openUserWindow()
Mudlet VersionAvailable in Mudlet4.15+
Parameters
  • windowName:
The name used to create the window element. Use "main" for the main console


Returns
  • Window type as string ("label", "miniconsole", "userwindow", or "commandline") or nil+error if it does not exist.
Example
-- Create a Geyser label and and check its type
testLabel = Geyser.Label:new({name = "testLabel"})
display(windowType(testLabel.name))  -- displays "label"

-- the main console returns "miniconsole" because it uses the same formatting functions
display(windowType("main")) -- displays "miniconsole"

-- check for the existence of a window
local windowName = "this thing does not exist"
local ok, err = windowType(windowName)
if ok then
  -- do things with it, as it does exist.
  -- the ok variable will hold the type of window it is ("label", "commandline", etc)
else
  cecho("<red>ALERT!! window does not exist")
end
Additional development notes

Discord Functions

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