Difference between revisions of "User:Molideus"

From Mudlet
Jump to navigation Jump to search
Line 1: Line 1:
 
{{TOC right}}
 
{{TOC right}}
{{#description2:Mudlet API documentation for functions that manipulate the mapper and its related features.}}
 
= Mapper Functions =
 
These are functions that are to be used with the Mudlet Mapper. The mapper is designed to be generic - it only provides the display and pathway calculations, to be used in Lua scripts that are tailored to the game you're playing. For a collection of pre-made scripts and general mapper talk, visit the [http://forums.mudlet.org/viewforum.php?f=13 mapper section] of the forums.
 
  
To register a script as a mapping one with Mudlet (so Mudlet knows the profile has one and won't bother the user when they open the map), please do this in your script:
+
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites.  
<syntaxhighlight lang="lua">
 
mudlet = mudlet or {}; mudlet.mapper_script = true
 
</syntaxhighlight>
 
  
==addAreaName==
+
Please use the [[Area_51/Template]] to add new entries in the sections below.
;areaID = addAreaName(areaName)
 
  
:Adds a new area name and returns the new (positive) area ID for the new name. If the name already exists, older versions of Mudlet returned -1 though since 3.0 the code will return ''nil'' and an error message.
+
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.
: See also: [[#deleteArea|deleteArea()]], [[#addRoom|addRoom()]]
+
:: <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!
  
;Example
+
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.
<syntaxhighlight lang="lua">
 
local newId, err = addAreaName("My House")
 
  
if newId == nil or newId < 1 or err then
 
  echo("That area name could not be added - error is: ".. err.."\n")
 
else
 
  cecho("<green>Created new area with the ID of "..newId..".\n")
 
end
 
</syntaxhighlight>
 
  
==addCustomLine==
+
=Basic Essential Functions=
;addCustomLine(roomID, id_to, direction, style, color, arrow)
+
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.
: See also: [[#getCustomLines|getCustomLines()]], [[#removeCustomLine|removeCustomLine()]]
 
  
:Adds a new/replaces an existing custom exit line to the 2D mapper for the room with the Id given.
+
=Database Functions=
 +
:A collection of functions for helping deal with the database.
  
;Parameters
+
=Date/Time Functions=
* ''roomID:''
+
: A collection of functions for handling date & time.
: Room ID to attach the custom line to.
 
* ''id_to:''
 
: EITHER: a room Id number, of a room on same area who's x and y coordinates are used as the other end of a SINGLE segment custom line (it does NOT imply that is what the exit it represent goes to, just the location of the end of the line);
 
: OR: a table of sets of THREE (x,y and z) coordinates in that order, x and y can be decimals, z is an integer ('''and must be present and be the same for all points on the line''', though it is irrelevant to what is produced as the line is drawn on the same z-coordinate as the room that the line is attached to!)
 
* ''direction:'' a string to associate the line with a valid exit direction, "n", "ne", "e", "se", "s", "sw", "w", "nw", "up", "down", "in" or "out" or a special exit (before Mudlet 3.17 this was case-sensitive and cardinal directions had to be uppercase).
 
* ''style:'' a string, one of: "solid line", "dot line", "dash line", "dash dot line" or "dash dot dot line" exactly.
 
* ''color:'' a table of three integers between 0 and 255 as the custom line color as the red, green and blue components in that order.
 
* ''arrow:'' a boolean which if true will set the custom line to have an arrow on the end of the last segment.
 
  
{{MudletVersion|3.0}}
+
=File System Functions=
 +
: A collection of functions for interacting with the file system.
  
;Examples
+
=Mapper Functions=
<syntaxhighlight lang="lua">
+
: A collection of functions that manipulate the mapper and its related features.
-- create a line from roomid 1 to roomid 2
 
addCustomLine(1, 2, "N", "dot line", {0, 255, 255}, true)
 
  
addCustomLine(1, {{4.5, 5.5, 3}, {4.5, 9.5, 3}, {6.0, 9.5, 3}}, "climb Rope", "dash dot dot line", {128, 128, 0}, false)
+
==updateMap==
</syntaxhighlight>
+
;updateMap()
  
A bigger example that'll create a new area and the room in it:
+
:Updates the mapper display (redraws it). While longer necessary since Mudlet 4.18, you can use this this function to redraw the map after changing it via API.
  
<syntaxhighlight lang="lua">
+
: See also: [[#centerview|centerview()]]
local areaid = addAreaName("my first area")
 
local newroomid = createRoomID()
 
addRoom(newroomid)
 
setRoomArea(newroomid, "my first area")
 
setRoomCoordinates(newroomid, 0, 0, 0)
 
 
 
local otherroomid = createRoomID()
 
addRoom(otherroomid)
 
setRoomArea(otherroomid, "my first area")
 
setRoomCoordinates(otherroomid, 0, 5, 0)
 
 
 
addSpecialExit(newroomid, otherroomid, "climb Rope")
 
addCustomLine(newroomid, {{4.5, 5.5, 3}, {4.5, 9.5, 3}, {6.0, 9.5, 3}}, "climb Rope", "dash dot dot line", {128, 128, 0}, false)
 
 
 
centerview(newroomid)
 
</syntaxhighlight>
 
 
 
==addMapEvent==
 
;addMapEvent(uniquename, event name, parent, display name, arguments)
 
 
 
:Adds a new entry to an existing mapper right-click entry. You can add one with addMapMenu. If there is no display name, it will default to the unique name (which otherwise isn't shown and is just used to differentiate this entry from others). ''event name'' is the Mudlet event that will be called when this is clicked on, and ''arguments'' will be passed to the handler function.
 
: See also: [[#addMapMenu|addMapMenu()]], [[#removeMapEvent|removeMapEvent()]], [[#getMapEvents|getMapEvents()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
addMapEvent("room a", "onFavorite") -- will make a label "room a" on the map menu's right click that calls onFavorite
+
-- delete a some room
 
+
deleteRoom(500)
addMapEvent("room b", "onFavorite", "Favorites", "Special Room!", 12345, "arg1", "arg2", "argn")  
+
-- now make the map show that it's gone
 +
updateMap()
 
</syntaxhighlight>
 
</syntaxhighlight>
The last line will make a label "Special Room!" under the "Favorites" menu that upon clicking will raise an event with all the arguments.
 
  
<syntaxhighlight lang="lua">
 
addMapMenu("Room type")
 
addMapEvent("markRoomsAsDeathTrap", "onMapMarkSelectedRooms", "Room type", "Mark selected rooms as Death Trap")
 
addMapEvent("markRoomsAsOneRoom", "onMapMarkSelectedRooms", "Room type", "Mark selected rooms as single-pass")
 
  
function onMapMarkSelectedRooms(event, markRoomType)
+
==mapSymbolFontInfo, PR #4038 closed==
  local selectedRooms = getMapSelection()["rooms"]
+
;mapSymbolFontInfo()
  for i, val in ipairs(selectedRooms) do
+
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
    if markRoomType == "markRoomsAsDeathTrap" then
 
      local r, g, b = unpack(color_table.black)
 
      --death trap
 
      setRoomEnv(val, 300)
 
      --death traps Env
 
      setCustomEnvColor(300, r, g, b, 255)
 
      setRoomChar(val, "☠️")
 
      lockRoom(val, true)
 
    elseif markRoomType == "markRoomsAsOneRoom" then
 
      local r, g, b = unpack(color_table.LightCoral)
 
      --single-pass
 
      setRoomEnv(val, 301)
 
      --one room Env
 
      setCustomEnvColor(301, r, g, b, 255)
 
      setRoomChar(val, "🚹")
 
    end
 
  end
 
  updateMap()
 
end
 
  
registerAnonymousEventHandler("onMapMarkSelectedRooms", "onMapMarkSelectedRooms")
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
</syntaxhighlight>
 
This create menu and two submenu options: "Mark selected rooms as Death Trap" and "Mark selected rooms as single-pass"
 
  
==addMapMenu==
+
;returns
;addMapMenu(uniquename, parent, display name)
+
* 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.
  
:Adds a new submenu to the right-click menu that opens when you right-click on the mapper. You can then add more submenus to it, or add entries with [[#addMapEvent|addMapEvent()]].
+
::As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialized, by activating a map window).
: See also: [[#addMapEvent|addMapEvent()]], [[#removeMapEvent|removeMapEvent()]], [[#getMapEvents|getMapEvents()]]
 
  
;Example
+
==moveMapLabel, PR #6014 open==
<syntaxhighlight lang="lua">
+
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
-- This will create a menu named: Favorites.
+
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).
addMapMenu("Favorites")
 
  
-- This will create a submenu with the unique id 'Favorites123' under 'Favorites' with the display name of 'More Favorites'.
+
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].
addMapMenu("Favorites1234343", "Favorites", "More Favorites")  
 
</syntaxhighlight>
 
  
==addRoom==
+
{{MudletVersion| ?.??}}
;addRoom(roomID)
 
  
:Creates a new room with the given ID, returns true if the room was successfully created.
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
 
 
{{note}} If you're not using incremental room IDs but room IDs stitched together from other factors or in-game hashes for room IDs - and your room IDs are starting off at 250+million numbers, you need to look into incrementally creating Mudlets room IDs with [[#createRoomID|createRoomID()]] and associating your room IDs with Mudlets via [[#setRoomIDbyHash|setRoomIDbyHash()]] and [[#getRoomIDbyHash|getRoomIDbyHash()]]. The reason being is that Mudlet's A* pathfinding implementation from boost cannot deal with extremely large room IDs because the resulting matrices it creates for pathfinding are enormously huge.
 
{{note}} Creating your own mapping script? Check out more [[Manual:Mapper#Making_your_own_mapping_script|information here]].
 
 
 
: See also: [[#createRoomID|createRoomID()]]
 
 
 
;Example:
 
<syntaxhighlight lang="lua">
 
local newroomid = createRoomID()
 
addRoom(newroomid)
 
</syntaxhighlight>
 
 
 
==addSpecialExit==
 
;addSpecialExit(roomIDFrom, roomIDTo, moveCommand)
 
 
 
:Creates a one-way from one room to another, that will use the given command for going through them.
 
 
 
: See also: [[#clearSpecialExits|clearSpecialExits()]], [[#removeSpecialExit|removeSpecialExit()]], [[#setExit|setExit()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- add a one-way special exit going from room 1 to room 2 using the 'pull rope' command
 
addSpecialExit(1, 2, "pull rope")
 
</syntaxhighlight>
 
 
 
Example in an alias:
 
<syntaxhighlight lang="lua">
 
-- sample alias pattern: ^spe (\d+) (.*?)$
 
-- currentroom is your current room ID in this example
 
addSpecialExit(currentroom,tonumber(matches[2]), matches[3])
 
echo("\n SPECIAL EXIT ADDED TO ROOMID:"..matches[2]..", Command:"..matches[3])
 
centerview(currentroom)
 
</syntaxhighlight>
 
 
 
==auditAreas==
 
;auditAreas()
 
 
 
: Initiates a consistency check on the whole map: All rooms, areas, and their composition. This is also done automatically whenever you first open your map, so probably seldom necessary to do manually. Will output findings to screen and/or logfile for later review.
 
 
 
: See also: [[#saveMap|saveMap()]], [[#removeMapEvent|removeMapEvent()]], [[#getMapEvents|getMapEvents()]]
 
 
 
==centerview==
 
;centerview (roomID)
 
 
 
:Centers the map view onto the given room ID. The map must be open to see this take effect. This function can also be used to see the map of an area if you know the number of a room there and the area and room are mapped.
 
 
 
: See also: [[#getPlayerRoom|getPlayerRoom()]], [[#updateMap|updateMap()]]
 
 
 
==clearAreaUserData==
 
;clearAreaUserData(areaID)
 
 
 
; Parameter
 
* areaID - ID number for area to clear.
 
 
 
:Clears all user data from a given area. Note that this will not touch the room user data.
 
: See also: [[#setAreaUserData|setAreaUserData()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#clearRoomUserData|clearRoomUserData()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(clearAreaUserData(34))
 
-- I did have data in that area, so it returns:
 
true
 
 
 
display(clearAreaUserData(34))
 
-- There is no data NOW, so it returns:
 
false
 
</syntaxhighlight>
 
 
 
{{MudletVersion|3.0}}
 
 
 
==clearAreaUserDataItem==
 
;clearAreaUserDataItem(areaID, key)
 
 
 
:Removes the specific key and value from the user data from a given area.
 
: See also: [[#setAreaUserData|setAreaUserData()]], [[#clearAreaUserData|clearAreaUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]
 
 
 
{{MudletVersion|3.0}}
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAllAreaUserData(34))
 
{
 
  description = [[<area description here>]],
 
  ruler = "Queen Morgase Trakand"
 
}
 
 
 
display(clearAreaUserDataItem(34,"ruler"))
 
true
 
 
 
display(getAllAreaUserData(34))
 
{
 
  description = [[<area description here>]],
 
}
 
 
 
display(clearAreaUserDataItem(34,"ruler"))
 
false
 
</syntaxhighlight>
 
 
 
==clearMapSelection==
 
;clearMapSelection()
 
 
 
:Clears any selected rooms from the map (i.e. they are highlighted in orange).
 
 
 
:Returns true if rooms are successfully cleared, false if nothing selected or cleared.
 
 
 
: See also [[#getMapSelection|getMapSelection()]]
 
 
 
==clearMapUserData==
 
;clearMapUserData()
 
 
 
:Clears all user data stored for the map itself. Note that this will not touch the area or room user data.
 
 
 
: See also: [[#setMapUserData|setMapUserData()]], [[#clearRoomUserData|clearRoomUserData()]], [[#clearAreaUserData|clearAreaUserData()]]
 
 
 
{{MudletVersion|3.0}}
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(clearMapUserData())
 
-- I did have user data stored for the map, so it returns:
 
true
 
 
 
display(clearMapUserData())
 
-- There is no data NOW, so it returns:
 
false
 
</syntaxhighlight>
 
 
 
==clearMapUserDataItem==
 
;clearMapUserDataItem(mapID, key)
 
 
 
:Removes the specific key and value from the user data from the map user data.
 
: See also: [[#setMapUserData|setMapUserData()]], [[#clearMapUserData|clearMapUserData()]], [[#clearAreaRoomUserData|clearAreaRoomUserData()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAllMapUserData())
 
{
 
  description = [[<map description here>]],
 
  last_modified = "1483228799"
 
}
 
 
 
display(clearMapUserDataItem("last_modified"))
 
true
 
 
 
display(getAllMapUserData())
 
{
 
  description = [[<map description here>]],
 
}
 
 
 
display(clearMapUserDataItem("last_modified"))
 
false
 
</syntaxhighlight>
 
 
 
{{MudletVersion|3.0}}
 
 
 
==clearRoomUserData==
 
;clearRoomUserData(roomID)
 
 
 
:Clears all user data from a given room.
 
: See also: [[#setRoomUserData|setRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]
 
 
 
{{note}} Returns a boolean true if any data was removed from the specified room and false if there was nothing to erase since Mudlet 3.0.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(clearRoomUserData(3441))
 
-- I did have data in that room, so it returns:
 
true
 
 
 
display(clearRoomUserData(3441))
 
-- There is no data NOW, so it returns:
 
false
 
</syntaxhighlight>
 
 
 
==clearRoomUserDataItem==
 
;clearRoomUserDataItem(roomID, key)
 
 
 
:Removes the specific key and value from the user data from a given room.
 
:Returns a boolean true if data was found against the give key in the user data for the given room and it is removed, will return false if exact key not present in the data. Returns nil if the room for the roomID not found.
 
: See also: [[#setRoomUserData|setRoomUserData()]], [[#clearRoomUserData|clearRoomUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAllRoomUserData(3441))
 
{
 
  description = [[
 
From this ledge you can see out across a large cavern to the southwest. The
 
east side of the cavern is full of stalactites and stalagmites and other
 
weird rock formations. The west side has a path through it and an exit to the
 
south. The sound of falling water pervades the cavern seeming to come from
 
every side. There is a small tunnel to your east and a stalactite within arms
 
reach to the south. It appears to have grown till it connects with the
 
stalagmite below it. Something smells... Yuck you are standing in bat guano!]],
 
  doorname_up = "trapdoor"
 
}
 
 
 
display(clearRoomUserDataItem(3441,"doorname_up"))
 
true
 
 
 
display(getAllRoomUserData(3441))
 
{
 
  description = [[
 
From this ledge you can see out across a large cavern to the southwest. The
 
east side of the cavern is full of stalactites and stalagmites and other
 
weird rock formations. The west side has a path through it and an exit to the
 
south. The sound of falling water pervades the cavern seeming to come from
 
every side. There is a small tunnel to your east and a stalactite within arms
 
reach to the south. It appears to have grown till it connects with the
 
stalagmite below it. Something smells... Yuck you are standing in bat guano!]],
 
}
 
 
 
display(clearRoomUserDataItem(3441,"doorname_up"))
 
false
 
</syntaxhighlight>
 
 
 
{{MudletVersion|3.0}}
 
 
 
==clearSpecialExits==
 
;clearSpecialExits(roomID)
 
 
 
:Removes all special exits from a room.
 
: See also: [[#addSpecialExit|addSpecialExit()]], [[#removeSpecialExit|removeSpecialExit()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
clearSpecialExits(1337)
 
 
 
if #getSpecialExits(1337) == 0 then -- clearSpecialExits will never fail on a valid room ID, this is an example
 
  echo("All special exits successfully cleared from 1337.\n")
 
end
 
</syntaxhighlight>
 
 
 
==closeMapWidget==
 
;closeMapWidget()
 
:closes (hides) the map window (similar to clicking on the map icon)
 
 
 
{{MudletVersion|4.7}}
 
: See also: [[#openMapWidget|openMapWidget()]], [[#moveMapWidget|moveMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
 
 
 
==connectExitStub==
 
;connectExitStub(fromID, direction) or connectExitStub(fromID, toID, [direction])
 
 
 
:Connects existing rooms with matching exit stubs. If you only give it a roomID and a direction, it'll work out which room should be linked to it that has an appropriate opposite exit stub and is located in the right direction. You can also just specify from and to room IDs, and it'll smartly use the right direction to link in. Lastly, you can specify all three arguments - fromID, toID and the direction (in that order) if you'd like to be explicit, or use [[#setExit|setExit()]] for the same effect.
 
  
 
;Parameters
 
;Parameters
* ''fromID:''
+
* ''areaID/Name:''
: Room ID to set the exit stub in.
+
: Area ID as number or AreaName as string containing the map label.
* ''direction:''
 
: You can either specify the direction to link the room in, and/or a specific room ID (see below). Direction can be specified as a number, short direction name ("nw") or long direction name ("northwest").
 
* ''toID:''
 
: The room ID to link this room to. If you don't specify it, the mapper will work out which room should be logically linked.
 
  
: See also: [[#setExitStub|setExitStub()]], [[#getExitStubs|getExitStubs()]]
+
* ''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.
  
;Example
+
* ''coordX/deltaX:''
<syntaxhighlight lang="lua">
+
: 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.
-- try and connect all stubs that are in a room
 
local stubs = getExitStubs(roomID)
 
if stubs then
 
  for i,v in pairs(stubs) do
 
    connectExitStub(roomID, v)
 
  end
 
end
 
</syntaxhighlight>
 
  
==createMapLabel==
+
* ''coordY/deltaY:''
;labelID = createMapLabel(areaID, text, posX, posY, posZ, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue[, zoom, fontSize, showOnTop, noScaling, fontName, foregroundTransparency, backgroundTransparency, temporary])
+
: 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.
  
: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.
+
* ''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.
  
: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.
+
* ''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'').
  
: See also: [[#getMapLabel|getMapLabel()]], [[#getMapLabels|getMapLabels()]], [[#deleteMapLabel|deleteMapLabel]], [[#createMapUmageLabel|createMapImageLabel()]]
+
;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.
{{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, from Mudlet version 4.17.0) 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.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- the first 50 is some area id, the next three 0,0,0 are coordinates - middle of the area
+
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
-- 255,0,0 would be the foreground in RGB, 23,0,0 would be the background RGB
+
moveMapLabel(0, 2, 3.0, 4.0)
-- 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 we add '\n' between lines
+
-- 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
-- the position is placed somewhat to the northeast of the center of the map
+
moveMapLabel(0, 2, -1.0, 0.0, false)
-- 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())
+
-- 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**:
createMapLabel(getRoomArea(getPlayerRoom()), "my map label", x,y,z, 255,0,0, 23,0,0, 0,20, false, true, "Ubuntu", 255, 100)
+
moveRoom(1, 2, -3.5, -2.0, true)
</syntaxhighlight>
 
  
==createMapImageLabel==
+
-- move the second label in the area with the ID number of 2, up three levels
;labelID = createMapImageLabel(areaID, filePath, posx, posy, posz, width, height, zoom, showOnTop[, temporary])
+
moveRoom(1, 2, 0.0, 0.0, 3.0)
  
:Creates an image label on the map at the given coordinates, with the given dimensions and zoom. You might find the default room and image size correlation to be too big - try reducing the width and height of the image then, while also zooming in the same amount. 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 external file available when the map file is loaded, can avoid expanding the size of the saved map considerably.
+
-- 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)
  
: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.
+
-- 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:
: See also: [[#createMapLabel|createMapLabel]], [[#deleteMapLabel|deleteMapLabel]]
+
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)
  
;Example:
+
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas
<syntaxhighlight lang="lua">
 
-- 138 is our pretend area ID
 
-- next, inside [[]]'s, is the exact location of our image
 
-- 0,0,0 are the x,y,z coordinates - so this will place it in the middle of the map
 
-- 482 is the width of the image - we divide it by 100 to scale it down, and then we'll zoom it by 100 - making the image take up about 4 rooms in width then
 
-- 555 is the original height of the image
 
-- 100 is how much we zoom it by, 1 would be no zoom
 
-- false to make it go below our rooms
 
-- (from 4.17.0) true to not save the label's image in the map file afterwards
 
createMapImageLabel(138, [[/home/vadi/Pictures/You only see what shown.png]], 0,0,0, 482/100, 555/100, 100, false, true)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==createMapper==
+
==moveRoom, PR #6010 open==
;createMapper([name of userwindow], x, y, width, height)
+
;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.
  
:Creates a miniconsole window for the mapper to render in, the with the given dimensions. You can only create one mapper at a time, and it is not currently possible to have a label on or under the mapper - otherwise, clicks won't register.
+
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]
  
{{note}} ''name of userwindow'' available in Mudlet 4.6.1+
+
{{MudletVersion| ?.??}}
  
{{Note}} If this command is ''not'' used then clicking on the Main Toolbar's '''Map''' button will create 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 '''Map''' button will toggle between showing and hiding the map whether it was created using the ''createMapper'' function or as a dock-able widget.
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010
 
 
;Example
 
<syntaxhighlight lang="lua">
 
createMapper(0,0,300,300) -- creates a 300x300 mapper in the top-left corner of Mudlet
 
setBorderLeft(305) -- adds a border so text doesn't underlap the mapper display
 
</syntaxhighlight>
 
 
 
<syntaxhighlight lang="lua">
 
-- another example:
 
local main = Geyser.Container:new({x=0,y=0,width="100%",height="100%",name="mapper container"})
 
 
local mapper = Geyser.Mapper:new({
 
  name = "mapper",
 
  x = "70%", y = 0, -- edit here if you want to move it
 
  width = "30%", height = "50%"
 
}, main)
 
</syntaxhighlight>
 
 
 
==createRoomID==
 
;usableId = createRoomID([minimumStartingRoomId])
 
 
 
:Returns the lowest possible room ID you can use for creating a new room. If there are gaps in room IDs your map uses it, this function will go through the gaps first before creating higher IDs.
 
  
 
;Parameters
 
;Parameters
* ''minimumStartingRoomId'' (optional, available in Mudlet 3.0+):
+
* ''roomID:''
: If provided, specifies a roomID to start searching for an empty one at, instead of 1. Useful if you'd like to ensure certain areas have specific room number ranges, for example. If you you're working with a huge map, provide the last used room ID to this function for an available roomID to be found a lot quicker.
+
: Room ID number to move.
  
: See also: [[#addRoom|addRoom()]]
+
* ''coordX/deltaX:''
 +
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
  
==deleteArea==
+
* ''coordY/deltaY:''
;deleteArea(areaID or areaName)
+
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
  
:Deletes the given area and all rooms in it. Returns ''true'' on success or ''nil'' + ''error message'' otherwise.
+
* ''coordZ/deltaZ:''
: See also: [[#addAreaName|addAreaName()]]
+
: (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.
  
;Parameters
+
* ''absoluteNotRelativeMove:''
* ''areaID:''
+
: (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'').
: Area ID to delete, or:
 
* ''areaName'' (available in Mudlet 3.0+):
 
: Area name to delete.
 
 
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- delete by areaID
 
deleteArea(23)
 
-- or since Mudlet 3.0, by area name
 
deleteArea("Big city")
 
</syntaxhighlight>
 
 
 
==deleteMap==
 
;deleteMap()
 
 
 
Deletes the entire map. This may be useful whilst initially setting up a mapper package for a new Game to clear faulty map data generated up to this point.
 
: See also: [[#loadMap|loadMap()]]
 
 
 
{{MudletVersion|4.14.0}}
 
  
 
;Returns
 
;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 - which will be the "blank" screen with a warning message of the form ''"No rooms in the map - load another one, or start mapping from scratch to begin."''
+
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.
 
 
{{note}} Prior to the introduction of this function, the recommended method to achieve the same result was to use [[#loadMap|loadMap()]] with a non-existent file-name, such as ''"_"'' however that would also cause an ''"[ ERROR ]"'' type message to appear on the profile's main console.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
deleteMap()
+
-- move the first room one space to the east and two spaces to the north
</syntaxhighlight>
+
moveRoom(1, 1, 2)
  
==deleteMapLabel==
+
-- move the first room one space to the west, note the final boolean argument is unneeded
;deleteMapLabel(areaID, labelID)
+
moveRoom(1, -1, 0, false)
  
:Deletes a map label from  a specific area.
+
-- 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**:
: See also: [[#createMapLabel|createMapLabel()]]
+
moveRoom(1, -3, -2, true)
  
;Example
+
-- move the second room up three levels
<syntaxhighlight lang="lua">
+
moveRoom(2, 0, 0, 3)
deleteMapLabel(50, 1)
 
</syntaxhighlight>
 
  
==deleteRoom==
+
-- move the second room one space to the west, note the last two arguments are unneeded
;deleteRoom(roomID)
+
moveRoom(2, -1, 0, 0, false)
  
:Deletes an individual room, and unlinks all exits leading to and from it.
+
-- 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)
  
;Example
+
-- all of the above will return the 'true'  boolean value assuming there are rooms with 1 and 2 as ID numbers
<syntaxhighlight lang="lua">
 
deleteRoom(335)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==disableMapInfo==
+
==setupMapSymbolFont, PR #4038 closed==
;disableMapInfo(label)
+
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
 +
:configures the font used for symbols in the (2D) map.
 +
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]
  
Disable the particular map info - same as toggling off checkbox from select box under mapper.
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
  
 
;Parameters
 
;Parameters
* ''label:''
+
* ''fontName'' one of:
: Name under which map info to be disabled was registered.
+
:* - 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.
  
: See also: [[#registerMapInfo|registerMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#killMapInfo|killMapInfo()]]
+
;Returns
 
+
* ''true'' on success
{{MudletVersion|4.11}}
+
* ''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).
 
 
==enableMapInfo==
 
;enableMapInfo(label)
 
 
 
Enable the particular map info - same as toggling on checkbox from select box under mapper.
 
  
;Parameters
+
=Miscellaneous Functions=
* ''label:''
+
: Miscellaneous functions.
: Name under which map info to be enabled was registered.
 
  
: See also: [[#registerMapInfo|registerMapInfo()]], [[#disableMapInfo|disableMapInfo()]], [[#killMapInfo|killMapInfo()]]
+
==compare, PR#7122 open==
  
{{MudletVersion|4.11}}
+
; sameValue = compare(a, b)
  
==getAllAreaUserData==
+
:This function takes two items, and compares their values. It will compare numbers, strings, but most importantly it will compare two tables by value, not reference. For instance, ''{} == {}'' is ''false'', but ''compare({}, {})'' is ''true''
;dataTable = getAllAreaUserData(areaID)
 
  
:Returns all the user data items stored in the given area ID; will return an empty table if there is no data stored or nil if there is no such area with that ID.
+
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]
  
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#searchAreaUserData|searchAreaUserData()]], [[#setAreaUserData|setAreaUserData()]]
+
{{MudletVersion|4.18}}
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAllAreaUserData(34))
 
--might result in:--
 
{
 
  country = "Andor",
 
  ruler = "Queen Morgase Trakand"
 
}
 
</syntaxhighlight>
 
 
 
{{MudletVersion|3.0}}
 
 
 
==getAllMapUserData==
 
;dataTable = getAllMapUserData()
 
 
 
:Returns all the user data items stored at the map level; will return an empty table if there is no data stored.
 
 
 
: See also: [[#getMapUserData|getMapUserData()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAllMapUserData())
 
--might result in:--
 
{
 
  description = [[This map is about so and so game]],
 
  author = "Bob",
 
  ["last updated"] = "December 5, 2020"
 
}
 
</syntaxhighlight>
 
 
 
{{MudletVersion|3.0}}
 
 
 
==getAllRoomEntrances==
 
;exitsTable = getAllRoomEntrances(roomID)
 
 
 
:Returns an indexed list of normal and special exits leading into this room. In case of two-way exits, this'll report exactly the same rooms as [[#getRoomExits|getRoomExits()]], but this function has the ability to pick up one-way exits coming into the room as well.
 
 
 
{{MudletVersion|3.0}}
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- print the list of rooms that have exits leading into room 512
 
for _, roomid in ipairs(getAllRoomEntrances(512)) do
 
  print(roomid)
 
end
 
</syntaxhighlight>
 
 
 
: See also: [[#getRoomExits|getRoomExits()]]
 
 
 
==getAllRoomUserData==
 
;dataTable = getAllRoomUserData(roomID)
 
 
 
:Returns all the user data items stored in the given room ID; will return an empty table if there is no data stored or nil if there is no such room with that ID. ''Can be useful if the user was not the one who put the data in the map in the first place!''
 
 
 
;See also: [[#getRoomUserDataKeys|getRoomUserDataKeys()]] - for a related command that only returns the data keys.
 
 
 
{{MudletVersion|3.0}}
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAllRoomUserData(3441))
 
--might result in:--
 
{
 
  description = [[
 
From this ledge you can see out across a large cavern to the southwest. The
 
east side of the cavern is full of stalactites and stalagmites and other
 
weird rock formations. The west side has a path through it and an exit to the
 
south. The sound of falling water pervades the cavern seeming to come from
 
every side. There is a small tunnel to your east and a stalactite within arms
 
reach to the south. It appears to have grown till it connects with the
 
stalagmite below it. Something smells... Yuck you are standing in bat guano!]],
 
  doorname_up = "trapdoor"
 
}
 
</syntaxhighlight>
 
 
 
==getAreaExits==
 
;roomTable = getAreaExits(areaID, showExits)
 
 
 
: Returns a table (indexed or key-value) of the rooms in the given area that have exits leading out to other areas - that is, border rooms.
 
 
 
;See also: [[#setExit|setExit()]], [[#getRoomExits|getRoomExits()]]
 
  
 
;Parameters
 
;Parameters
* ''areaID:''
+
* ''a:''
: Area ID to list the exits for.
+
: The first item to compare
* ''showExits:''
+
* ''b:''
: Boolean argument, if true then the exits that lead out to another area will be listed for each room.
+
: The second item to compare
  
 +
;Returns
 +
* Boolean true if the items have the same value, otherwise boolean false
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- list all border rooms for area 44:
+
local tblA = { 255, 0, 0 }
getAreaExits(44)
+
local tblB = color_table.red
 
+
local same = compare(tblA, tblB)
-- returns:
+
display(same)
--[[
+
-- this will return true
{
+
display(tblA == tblB)
  7091,
+
-- this will display false, as they are different tables
  10659,
+
-- even though they have the same value
  11112,
 
  11122,
 
  11133,
 
  11400,
 
  12483,
 
  24012
 
}
 
]]
 
 
 
-- list all border rooms for area 44, and the exits within them that go out to other areas:
 
getAreaExits(44, true)
 
--[[
 
{
 
  [12483] = {
 
    north = 27278
 
  },
 
  [11122] = {
 
    ["enter grate"] = 14551
 
  },
 
  [11112] = {
 
    ["enter grate"] = 14829
 
  },
 
  [24012] = {
 
    north = 22413
 
  },
 
  [11400] = {
 
    south = 10577
 
  },
 
  [11133] = {
 
    ["enter grate"] = 15610
 
  },
 
  [7091] = {
 
    down = 4411
 
  },
 
  [10659] = {
 
    ["enter grate"] = 15510
 
  }
 
}
 
]]
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getAreaRooms==
+
; Additional development notes
;getAreaRooms(area id)
+
This is just exposing the existing _comp function, which is currently the best way to compare two tables by value. --[[User:Demonnic|Demonnic]] ([[User talk:Demonnic|talk]]) 18:51, 7 February 2024 (UTC)
  
:Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or ''nil'' if no such area exists.
+
==createVideoPlayer, PR #6439==
 +
;createVideoPlayer([name of userwindow], x, y, width, height)
  
;Example
+
: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.
<syntaxhighlight lang="lua">
 
-- using the sample findAreaID() function defined in the getAreaTable() example,
 
-- we'll define a function that echo's us a nice list of all rooms in an area with their ID
 
function echoRoomList(areaname)
 
  local id, msg = findAreaID(areaname)
 
  if id then
 
    local roomlist, endresult = getAreaRooms(id), {}
 
 
 
    -- obtain a room list for each of the room IDs we got
 
    for _, id in pairs(roomlist) do
 
      endresult[id] = getRoomName(id)
 
    end
 
 
 
    -- now display something half-decent looking
 
    cecho(string.format(
 
      "List of all rooms in %s (%d):\n", msg, table.size(endresult)))
 
  
    for roomid, roomname in pairs(endresult) do
+
{{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.
      cecho(string.format(
 
        "%6s: %s\n", roomid, roomname))
 
    end
 
  elseif not id and msg then
 
    echo("ID not found; " .. msg)
 
  else
 
    echo("No areas matched the query.")
 
  end
 
end
 
</syntaxhighlight>
 
  
==getAreaTable==
+
{{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.
;areaTable = getAreaTable()
 
  
:Returns a key(area name)-value(area id) table with all known areas and their IDs.
+
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]]
{{Note}} Some older versions of Mudlet return an area with an empty name and an ID of 0 included in it, you should ignore that.
 
  
;See also: [[#getAreaTableSwap|getAreaTableSwap()]]
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- example function that returns the area ID for a given area
+
-- Create a 300x300 video player in the top-left corner of Mudlet
 +
createVideoPlayer(0,0,300,300)
  
function findAreaID(areaname)
+
-- Alternative examples using Geyser.VideoPlayer
  local list = getAreaTable()
+
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})
 
+
  -- iterate over the list of areas, matching them with substring match.  
+
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({
  -- if we get match a single area, then return it's ID, otherwise return
+
  name = "GUI.VideoPlayer",
  -- 'false' and a message that there are than one are matches
+
  x = "70%", y = 0, -- edit here if you want to move it
  local returnid, fullareaname
+
   width = "30%", height = "50%"
  for area, id in pairs(list) do
+
}, GUI.Right)
    if area:find(areaname, 1, true) then
 
      if returnid then return false, "more than one area matches" end
 
      returnid = id; fullareaname = area
 
    end
 
  end
 
 
 
  return returnid, fullareaname
 
end
 
 
 
-- sample use:
 
local id, msg = findAreaID("blahblah")
 
if id then
 
   echo("Found a matching ID: " .. id)
 
elseif not id and msg then
 
  echo("ID not found: " .. msg)
 
else
 
  echo("No areas matched the query.")
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getAreaTableSwap==
+
==loadVideoFile, PR #6439==
;areaTable = getAreaTableSwap()
+
;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.
:Returns a key(area id)-value(area name) table with all known areas and their IDs. Unlike getAreaTable which won't show you all areas with the same name by different IDs, this function will.
 
{{Note}} Some older versions of Mudlet return an area with an empty name and an ID of 0 included in it, you should ignore that.
 
 
 
==getAreaUserData==
 
;dataValue = getAreaUserData(areaID, key)
 
 
 
:Returns a specific data item stored against the given key for the given area ID number.  This is very like the corresponding Room User Data command but intended for per area rather than for per room data (for storage of data relating to the whole map see the corresponding Map User Data commands.)
 
 
 
:Returns the user data value (string) stored at a given room with a given key (string), or a Lua ''nil'' and an error message if the key is not present in the Area User Data for the given Area ID. Use [[#setAreaUserData|setAreaUserData()]] function for storing the user data.
 
 
 
;See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]], [[#setAreaUserData|setAreaUserData()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display(getAreaUserData(34, "country"))
 
-- might produce --
 
"Andor"
 
</syntaxhighlight>
 
 
 
==getCustomEnvColorTable==
 
;envcolors = getCustomEnvColorTable()
 
 
 
:Returns a table with customized environments, where the key is the environment ID and the value is a indexed table of rgb values.
 
: See also: [[#setCustomEnvColor|setCustomEnvColor()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
{
 
  envid1 = {r, g, b, alpha},
 
  envid2 = {r, g, b, alpha}
 
}
 
</syntaxhighlight>
 
 
 
==getCustomLines==
 
;lineTable = getCustomLines(roomID)
 
: See also: [[#addCustomLine|addCustomLine()]], [[#removeCustomLine|removeCustomLine()]]
 
 
 
:Returns a table including all the details of the custom exit lines, if any, for the room with the id given.
 
 
 
;Parameters
 
* ''roomID:''
 
: Room ID to return the custom line details of.
 
 
 
{{MudletVersion|3.0.}}
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display getCustomLines(1)
 
{
 
  ["climb Rope"] = {
 
    attributes = {
 
      color = {
 
        b = 0,
 
        g = 128,
 
        r = 128
 
      },
 
      style = "dash dot dot line",
 
      arrow = false
 
    },
 
    points = {
 
      {
 
        y = 9.5,
 
        x = 4.5
 
      },
 
      {
 
        y = 9.5,
 
        x = 6
 
      },
 
      [0] = {
 
        y = 5.5,
 
        x = 4.5
 
      }
 
    }
 
  },
 
  N = {
 
    attributes = {
 
      color = {
 
        b = 255,
 
        g = 255,
 
        r = 0
 
      },
 
      style = "dot line",
 
      arrow = true
 
    },
 
    points = {
 
      [0] = {
 
        y = 27,
 
        x = -3
 
      }
 
    }
 
  }
 
}
 
</syntaxhighlight>
 
 
 
==getCustomLines1==
 
;lineTable = getCustomLines1(roomID)
 
This is a replacement for ''getCustomLines(...)'' that outputs the tables for the coordinates for the points on the custom line in an order and format that can be fed straight back into an ''addCustomLine(...)'' call; similarly the color parameters are also reported in the correct format to also be reused in the same manner. This function is intended to make it simpler for scripts to manipulate such lines.
 
:See also: [[Manual:Mapper_Functions#addCustomLine|addCustomLine()]], [[Manual:Mapper_Functions#removeCustomLine|removeCustomLine()]], [[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]
 
{{MudletVersion| 4.16}}
 
 
 
;Parameters
 
* ''roomID:''
 
:Room ID to return the custom line details of.
 
 
 
;Returns
 
:a table including all the details of the custom exit lines, if any, for the room with the id given.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display getCustomLines1(1)
 
{
 
  ["climb Rope"] = {
 
    attributes = {
 
      color = { 128, 128, 0 },
 
      style = "dash dot dot line",
 
      arrow = false
 
    },
 
    points = { { 4.5, 5.5, 3 }, { 4.5, 9.5, 3 }, { 6, 9.5, 3 } }
 
  },
 
  N = {
 
    attributes = {
 
      color = { 0, 255, 255 },
 
      style = "dot line",
 
      arrow = true
 
    },
 
    points = { { -3, 27, 3 } }
 
  }
 
}
 
</syntaxhighlight>
 
  
==getDoors==
+
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.
;doors = getDoors(roomID)
 
  
:Returns a key-value table with the cardinal direction as the key and the door value as a number. If there are no doors in a room, it returns an empty table.
+
{| 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.
 +
|-
 +
|}
  
;Parameters
+
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]]
* ''roomID:''
 
: Room ID to check for doors in.
 
  
: See also: [[#setDoor|setDoor()]]
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
 
-- an example that displays possible doors in room 2334
 
local doors = getDoors(2334)
 
  
if not next(doors) then cecho("\nThere aren't any doors in room 2334.") return end
 
 
local door_status = {"open", "closed", "locked"}
 
 
for direction, door in pairs(doors) do
 
  cecho("\nThere's a door leading in "..direction.." that is "..door_status[door]..".")
 
end
 
</syntaxhighlight>
 
 
==getExitStubs==
 
;stubs = getExitStubs(roomid)
 
 
:Returns an indexed table (starting at 0) of the direction #'s that have an exit stub marked in them. You can use this information to connect earlier-made exit stubs between rooms when mapping.
 
 
: See also: [[#setExitStub|setExitStub()]], [[#connectExitStub|connectExitStub()]], [[#getExitStubs1|getExitStubs1()]]
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- show the exit stubs in room 6 as numbers
+
---- Table Parameter Syntax ----
local stubs = getExitStubs(6)
 
for i = 0, #stubs do print(stubs[i]) end
 
</syntaxhighlight>
 
 
 
{{note}} Previously would throw a lua error on non-existent room - now returns nil plus error message (as does other run-time errors) - previously would return just a nil on NO exit stubs but now returns a notification error message as well, to aide disambiguation of the nil value.
 
 
 
==getExitStubs1==
 
;stubs = getExitStubs1(roomid)
 
  
:Returns an indexed table (starting at 1) of the direction #'s that have an exit stub marked in them. You can use this information to connect earlier-made exit stubs between rooms when mapping. As this function starts indexing from 1 as it is default in Lua, you can use ipairs() to iterate over the results.
+
-- Download from the Internet
 +
loadVideoFile({
 +
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
})
  
; See also: [[#getExitStubs|getExitStubs()]]
+
-- OR download from the profile
 +
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
  
;Example
+
-- OR download from the local file system
<syntaxhighlight lang="lua">
+
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
-- show the exit stubs in room 6 as numbers
 
for k,v in ipairs(getExitStubs1(6)) do print(k,v) end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
==getExitWeights==
 
;weights = getExitWeights(roomid)
 
 
:Returns a key-value table of the exit weights that a room has, with the direction or special exit as a key and the value as the exit weight. If a weight for a direction wasn't yet set, it won't be listed.
 
 
;Parameters
 
* ''roomid:''
 
: Room ID to view the exit weights in.
 
 
: See also: [[#setExitWeight|setExitWeight()]]
 
 
==getGridMode==
 
;TrueOrFalse = getGridMode(areaID)
 
 
:Use this to see, if a specific area has grid/wilderness view mode set. This way, you can also calculate from a script, how many grid areas a map has got in total.
 
 
{{MudletVersion|3.11}}
 
 
;Parameters
 
* ''areaID:''
 
: Area ID (number) to view the grid mode of.
 
 
: See also: [[#setGridMode|setGridMode()]]
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
getGridMode(55)
+
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
-- will return: false
 
setGridMode(55, true) -- set area with ID 55 to be in grid mode
 
getGridMode(55)
 
-- will return: true
 
</syntaxhighlight>
 
  
==getMapEvents==
+
-- Download from the Internet
; mapevents = getMapEvents()
+
loadVideoFile(
 +
    "TextInMotion-VideoSample-1080p.mp4"
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
)
  
: Returns a list of map events currently registered. Each event is a dictionary with the keys ''uniquename'', ''parent'', ''event name'', ''display name'', and ''arguments'', which correspond to the arguments of ''addMapEvent()''.
+
-- OR download from the profile
: See also: [[#addMapMenu|addMapMenu()]], [[#removeMapEvent|removeMapEvent()]], [[#addMapEvent|addMapEvent()]]
+
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
  
;Example
+
-- OR download from the local file system
<syntaxhighlight lang="lua">
+
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
addMapEvent("room a", "onFavorite") -- will make a label "room a" on the map menu's right click that calls onFavorite
 
 
 
addMapEvent("room b", "onFavorite", "Favorites", "Special Room!", 12345, "arg1", "arg2", "argn")
 
 
 
local mapEvents = getMapEvents()
 
for _, event in ipairs(mapEvents) do
 
  echo(string.format("MapEvent '%s' is bound to event '%s' with these args: '%s'", event["uniquename"], event["event name"], table.concat(event["arguments"], ",")))
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|3.3}}
+
==playVideoFile, PR #6439==
 +
;playVideoFile(settings table)
 +
:Plays video files from the Internet or the local file system for later use with [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]]. Video files may be downloaded to the device and played, or streamed from the Internet when the value of the <code>stream</code> parameter is <code>true</code>.
  
==getMapLabel==
+
{| class="wikitable"
;labelinfo = getMapLabel(areaID, labelID or labelText)
+
!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.
 +
|-
 +
| 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.
 +
|-
 +
|}
  
:Returns a key-value table describing that particular label in an area. Keys it contains are the ''X'', ''Y'', ''Z'' coordinates, ''Height'' and ''Width'', ''BgColor'', ''FgColor'', ''Pixmap'', and the ''Text'' it contains. If the label is an image label, then ''Text'' will be set to the ''no text'' string.
+
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]]
  
:''BgColor'' and ''FgColor'' are tables with ''r'',''g'',''b'' keys, each holding ''0-255'' color component value.
+
{{MudletVersion|4.??}}
 
 
:''Pixmap'' is base64 encoded image of label.
 
 
 
{{note}} ''BgColor'', ''FgColor'', ''Pixmap'' are available in Mudlet 4.11+
 
 
 
;Parameters
 
* ''areaID:'' areaID from which to retrieve label
 
* ''labelID:'' labelID (''getMapLabels'' return table key) or labelText (exact match)
 
 
 
See also: [[#createMapLabel|createMapLabel()]], [[#getMapLabels|getMapLabels()]]
 
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
 
lua getMapLabels(52)
 
{
 
  "no text",
 
  [0] = "test"
 
}
 
 
lua getMapLabel(52, 0)
 
{
 
  Y = -2,
 
  X = -8,
 
  Z = 11,
 
  Height = 3.9669418334961,
 
  Text = "test",
 
  Width = 8.6776866912842,
 
  BgColor = {
 
    b = 0,
 
    g = 0,
 
    r = 0
 
  },
 
  FgColor = {
 
    b = 50,
 
    g = 255,
 
    r = 255
 
  },
 
  Pixmap = "iVBORw0KG(...)lFTkSuQmCC" -- base64 encoded png image (shortened for brevity)
 
}
 
 
lua getMapLabel(52, "no text")
 
{
 
  Y = 8,
 
  X = -15,
 
  Z = 11,
 
  Height = 7.2520666122437,
 
  Text = "no text"
 
  Width = 11.21900844574,
 
  BgColor = {
 
    b = 0,
 
    g = 0,
 
    r = 0
 
  },
 
  FgColor = {
 
    b = 50,
 
    g = 255,
 
    r = 255
 
  },
 
  Pixmap = "iVBORw0KG(...)lFTkSuQmCC" -- base64 encoded png image (shortened for brevity)
 
}
 
</syntaxhighlight>
 
 
==getMapLabels==
 
;arealabels = getMapLabels(areaID)
 
 
:Returns an indexed table (that starts indexing from 0) of all of the labels in the area, plus their label text. You can use the label id to [[#deleteMapLabel|deleteMapLabel()]] it.
 
:If there are no labels in the area at all, it will return an empty table.
 
 
: See also: [[#createMapLabel|createMapLabel()]], [[#getMapLabel|getMapLabel()]], [[#deleteMapLabel|deleteMapLabel()]]
 
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getMapLabels(43))
+
---- Table Parameter Syntax ----
table {
 
  0: ''
 
  1: 'Waterways'
 
}
 
 
 
deleteMapLabel(43, 0)
 
display(getMapLabels(43))
 
table {
 
  1: 'Waterways'
 
}
 
</syntaxhighlight>
 
 
 
==getMapMenus==
 
;getMapMenus()
 
  
:Returns a table with the available map menus as key-value in the format of <code>map menu - parent item</code>. If an item is positioned at the menu's top-level, the value will say <code>top-level</code>.
+
-- Stream a video file from the Internet and play it.
:If you haven't opened a map yet, getMapMenus() will return nil+error message. If you don't have any map labels yet, an empty table <code>{}</code> is returned.
+
playVideoFile({
 +
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
    , stream = true
 +
})
  
: See also: [[#addMapMenu|addMapMenu()]], [[#addMapEvent|addMapEvent()]]
+
-- 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.
  
;Example
+
playVideoFile({
<syntaxhighlight lang="lua">
+
    name = "TextInMotion-VideoSample-1080p.mp4"
-- given the following menu structure:
+
     , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
top-level
+
})
  menu1
 
    menu1.1
 
      action1.1.1
 
     menu1.2
 
      action1.2.1
 
  menu2
 
  
getMapMenus() -- will return:
+
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
{
+
playVideoFile({
  menu2 = "top-level",
+
    name = "TextInMotion-VideoSample-1080p.mp4"
  menu1.2 = "menu1",
+
})
  menu1.1 = "menu1",
 
  menu1 = "top-level"
 
}
 
</syntaxhighlight>
 
  
==getMapSelection==
+
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
; getMapSelection()
+
---- [volume] of 75 (1 to 100)
 +
playVideoFile({
 +
    name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"
 +
    , volume = 75
 +
})
  
:Returns a table containing details of the current mouse selection in the 2D mapper.
+
-- 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
 +
})
  
:Reports on one or more rooms being selected (i.e. they are highlighted in orange).
+
-- 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
:The contents of the table will vary depending on what is currently selected. If the selection is of map rooms then there will be keys of ''center'' and ''rooms'': the former will indicates the center room (the one with the yellow cross-hairs) if there is more than one room selected or the only room if there is only one selected (there will not be cross-hairs in that case); the latter will contain a list of the one or more rooms.
+
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
 
+
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
; Example - several rooms selected
+
---- [key] reference of "text" for stopping this unique video later
<syntaxhighlight lang="lua">
+
---- [tag] reference of "ambience" to stop any video later with the same tag
display(getMapSelection())
+
---- [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
  center = 5013,
+
---- [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)
  rooms = {
+
playVideoFile({
     5011,
+
    name = "TextInMotion-VideoSample-1080p.mp4"
     5012,
+
    , volume = nil -- nil lines are optional, no need to use
     5013,
+
    , fadein = 10000
     5014,
+
     , fadeout = 15000
     5018,
+
     , start = 5000
     5019,
+
     , loops = nil -- nil lines are optional, no need to use
     5020
+
     , key = "text"
  }
+
     , tag = "ambience"
}
+
     , continue = true
 +
     , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
    , stream = false
 +
})
 
</syntaxhighlight>
 
</syntaxhighlight>
; Example - one room selected
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getMapSelection())
+
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----
{
 
  center = 5013,
 
  rooms = {
 
    5013
 
  }
 
}
 
</syntaxhighlight>
 
; Example - no or something other than a room selected
 
<syntaxhighlight lang="lua">
 
display(getMapSelection())
 
{
 
}
 
</syntaxhighlight>
 
  
{{MudletVersion|3.17}}
+
-- 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
 +
)
  
==getMapUserData==
+
-- 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.
;getMapUserData( key )
+
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
 +
)
  
;Parameters
+
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
* ''key:''
+
playVideoFile(
: string used as a key to select the data stored in the map as a whole.
+
    "TextInMotion-VideoSample-1080p.mp4"  -- name
 +
)
  
:Returns the user data item (string); will return a nil+error message if there is no data with such a key in the map data.
+
-- 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
 +
)
  
: See also: [[#getAllMapUserData|getAllMapUserData()]], [[#setMapUserData|setMapUserData()]]
+
-- 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
 +
)
  
;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
display(getMapUserData("last updated"))
+
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
--might result in:--
+
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
"December 5, 2020"
+
---- [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
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|3.0}}
 
 
==getMapZoom==
 
;getMapZoom([areaID])
 
 
:Gets the current 2D map zoom level. Added in '''Mudlet ''4.17.0''''' also with the option to get the zoom for an area to be specified even if it is not the one currently being viewed. This change is combined with Mudlet remembering the zoom level last used for each area and with the revision of the ''setMapZoom()'' function to also take an areaID to work on instead of the current area being viewed in the map.
 
  
:See also: [[Manual:Mapper_Functions#setMapZoom|setMapZoom()]].
+
==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()]].
  
{{MudletVersion| 4.17.0}}
+
{| 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.
 +
|-
 +
|}
  
;Parameters
+
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]]
* ''areaID:''
 
: Area ID number to get the 2D zoom for (''optional'', the function works on the area currently being viewed if this is omitted).
 
  
;Returns
+
{{MudletVersion|4.??}}
* A floating point number on success
 
* ''nil'' and an error message on failure.
 
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
 
echo("\nCurrent zoom level: " .. getMapZoom() .. "\n")
 
-- Could be anything from 3 upwards:
 
  
Current zoom level: 42.4242
 
 
setMapZoom(2.5 + getMapZoom(1), 1) -- zoom out the area with ID 1 by 2.5
 
true
 
</syntaxhighlight>
 
 
{{note}} The precise meaning of a particular zoom value may have an underlying meaning however that has not been determined other than that the minimum value is ''3.0'' and the initial value - and what prior Mudlet versions started each session with - is ''20.0''.
 
 
==getPath==
 
;getPath(roomID from, roomID to)
 
 
:Returns a boolean true/false if a path between two room IDs is possible. If it is, the global ''speedWalkDir'' table is set to all of the directions that have to be taken to get there, and the global ''speedWalkPath'' table is set to all of the roomIDs you'll encounter on the way, and as of 3.0, ''speedWalkWeight'' will return all of the room weights. Additionally returns the total cost (all weights added up) of the path after the boolean argument in 3.0.
 
 
 
: See also: [[Manual:Lua_Functions#translateTable|translateTable()]]
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- check if we can go to room 155 from room 34 - if yes, go to it
+
---- Table Parameter Syntax ----
if getPath(34,155) then
 
  gotoRoom(155)
 
else
 
  echo("\nCan't go there!")
 
end
 
</syntaxhighlight>
 
  
==getPlayerRoom==
+
-- Stop all playing video files for this profile associated with the API
;getPlayerRoom()
+
stopVideos()
  
:Returns the current player location as set by [[#centerview|centerview()]].
+
-- Stop playing the text mp4 by name
 +
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
  
: See also: [[#centerview|centerview]]
+
-- Stop playing the unique sound identified as "text"
 
+
stopVideos({
;Example
+
    name = nil  -- nil lines are optional, no need to use
<syntaxhighlight lang="lua">
+
    , key = "text" -- key
display("We're currently in " .. getRoomName(getPlayerRoom()))
+
    , tag = nil  -- nil lines are optional, no need to use
 +
})
 
</syntaxhighlight>
 
</syntaxhighlight>
 
{{MudletVersion|3.14}}
 
 
==getRoomArea==
 
;getRoomArea(roomID)
 
 
:Returns the area ID of a given room ID. To get the area name, you can check the area ID against the data given by [[#getAreaTable | getAreaTable()]] function, or use the [[#getRoomAreaName |getRoomAreaName()]] function.
 
 
{{note}} If the room ID does not exist, this function will raise an error.
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display("Area ID of room #100 is: "..getRoomArea(100))
+
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
  
display("Area name for room #100 is: "..getRoomAreaName(getRoomArea(100)))
+
-- Stop all playing video files for this profile associated with the API
</syntaxhighlight>
+
stopVideos()
 
 
==getRoomAreaName==
 
;getRoomAreaName(areaID or areaName)
 
 
 
:Returns the area name for a given area id; or the area id for a given area name.
 
  
{{note}} Despite the name, this function will not return the area name for a given ''room'' id (or room name) directly. However, renaming or revising it would break existing scripts.
+
-- Stop playing the text mp4 by name
 +
stopVideos("TextInMotion-VideoSample-1080p.mp4")
  
;Example
+
-- Stop playing the unique sound identified as "text"
<syntaxhighlight lang="lua">
+
stopVideos(
echo(string.format("room id #455 is in %s.", getRoomAreaName(getRoomArea(455))))
+
    nil -- name
 +
    , "text" -- key
 +
    , nil -- tag
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
==getRoomChar==
+
==getCustomLoginTextId, PR #3952 open==
;getRoomChar(roomID)
+
;getCustomLoginTextId()
 
 
:Returns the single ASCII character that forms the ''symbol'' for the given room id.
 
 
 
: '''Since Mudlet version 3.8 :''' this facility has been extended:
 
: Returns the string (UTF-8) that forms the ''symbol'' for the given room id; this may have been set with either [[#setRoomChar|setRoomChar()]] or with the ''symbol'' (was ''letter'' in prior versions) context menu item for rooms in the 2D Map.
 
  
==getRoomCharColor==
+
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.
;r,g,b = getRoomCharColor(roomID)
 
  
:Returns the color of the Room Character as a set of r,g,b color coordinates.
+
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()]].
  
;See also: [[Manual:Lua_Functions#setRoomCharColor|setRoomCharColor()]], [[Manual:Lua_Functions#getRoomChar|getRoomChar()]]
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
  
;Parameters
+
Only one custom login text has been defined initially:
* ''roomID:''
+
{| class="wikitable"
: The room ID to get the room character color from
+
|+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.
* The color as 3 separate numbers, red, green, and blue from 0-255
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- gets the color of the room character set on room 12345. If no room character is set the default 'color' is 0,0,0
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
local r,g,b = getRoomCharColor(12345)
+
function doLogin()
decho(f"Room Character for room 12345 is <{r},{g},{b}>this color.<r> It is made up of <{r},0,0>{r} red<r>, <0,{g},0>{g} green<r>, <0,0,{b}> {b} blue<r>.\")
+
  if getCustomLoginTextId() ~= 1 then
</syntaxhighlight>
+
     -- 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")
==getRoomCoordinates==
+
   else
;x,y,z = getRoomCoordinates(roomID)
+
    tempTime(2.0, [[sendCustomLoginText()]], 1)
 
 
:Returns the room coordinates of the given room ID.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
local x,y,z = getRoomCoordinates(roomID)
 
echo("Room Coordinates for "..roomID..":")
 
echo("\n     X:"..x)
 
echo("\n     Y:"..y)
 
echo("\n    Z:"..z)
 
</syntaxhighlight>
 
 
 
<syntaxhighlight lang="lua">
 
-- A quick function that will find all rooms on the same z-position in an area; this is useful if, say, you want to know what all the same rooms on the same "level" of an area is.
 
function sortByZ(areaID, zval)
 
   local area = getAreaRooms(areaID)
 
  local t = {}
 
  for _, id in ipairs(area) do
 
    local _, _, z = getRoomCoordinates(id)
 
    if z == zval then
 
      table.insert(t, id)
 
    end
 
 
   end
 
   end
  return t
 
end
 
</syntaxhighlight>
 
 
==getRoomEnv==
 
;envID = getRoomEnv(roomID)
 
 
:Returns the environment ID of a room. The mapper does not store environment names, so you'd need to keep track of which ID is what name yourself.
 
 
;Example
 
<syntaxhighlight lang="lua">
 
function checkID(id)
 
  echo(string.format("The env ID of room #%d is %d.\n", id, getRoomEnv(id)))
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== getRoomExits ==
+
==sendCharacterName, PR #3952 open==
;getRoomExits (roomID)
+
;sendCharacterName()
:Returns the currently known non-special exits for a room in an key-index form: ''exit = exitroomid''.
 
  
: See also: [[#getSpecialExits|getSpecialExits()]]
+
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.
  
;Example
+
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.
<syntaxhighlight lang="lua">
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
table {
 
  'northwest': 80
 
  'east': 78
 
}
 
</syntaxhighlight>
 
  
Here's a practical example that queries the rooms around you and searched for one of the water environments (the number would depend on how it was mapped):
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
  
<syntaxhighlight lang="lua">
+
==sendCharacterPassword, PR #3952 open==
local exits = getRoomExits(mycurrentroomid)
+
;sendCharacterPassword()
for direction,num in pairs(exits) do
 
  local env_num = getRoomEnv(num)
 
  if env_num == 22 or env_num == 20 or env_num == 30 then
 
    print("There's water to the "..direction.."!")
 
  end
 
end</syntaxhighlight>
 
  
==getRoomHashByID==
+
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.
;getRoomHashByID(roomID)
 
  
:Returns a room hash that is associated with a given room ID in the mapper. This is primarily for games that make use of hashes instead of room IDs. It may be used to share map data while not sharing map itself. ''nil'' is returned if no room is not found.
+
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function, reproduced below, that may be replaced for more sophisticated requirements.
 +
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].
  
: See also: [[#getRoomIDbyHash|getRoomIDbyHash()]]
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
{{MudletVersion|3.13.0}}
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
    for id,name in pairs(getRooms()) do
+
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
        local h = getRoomUserData(id, "herbs")
+
function doLogin()
        if h ~= "" then
+
  if getCharacterName() ~= "" then
            echo(string.format([[["%s"] = "%s",]], getRoomHashByID(id), h))
+
    tempTime(2.0, [[sendCharacterName()]], 1)
            echo("\n")
+
     tempTime(3.0, [[sendCharacterPassword()]], 1)
        end
+
   end
     end
 
</syntaxhighlight>
 
 
 
==getRoomIDbyHash==
 
;roomID = getRoomIDbyHash(hash)
 
 
 
:Returns a room ID that is associated with a given hash in the mapper. This is primarily for games that make use of hashes instead of room IDs (like [http://avalon.mud.de/index.php?enter=1 Avalon.de]). ''-1'' is returned if no room ID matches the hash.
 
 
 
: See also: [[#getRoomHashByID|getRoomHashByID()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- example taken from http://forums.mudlet.org/viewtopic.php?f=13&t=2177
 
local id = getRoomIDbyHash("5dfe55b0c8d769e865fd85ba63127fbc")
 
if id == -1 then
 
  id = createRoomID()
 
   setRoomIDbyHash(id, "5dfe55b0c8d769e865fd85ba63127fbc")
 
  addRoom(id)
 
  setRoomCoordinates(id, 0, 0, -1)
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomName==
+
==sendCustomLoginText, PR #3952 open ==
;getRoomName(roomID)
+
;sendCustomLoginText()
  
:Returns the room name for a given room id.
+
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.
  
;Example
+
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.
<syntaxhighlight lang="lua">
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
echo(string.format("The name of the room id #455 is %s.", getRoomName(455))
 
</syntaxhighlight>
 
 
 
==getRooms==
 
;rooms = getRooms()
 
 
 
:Returns the list of '''all''' rooms in the map in the whole map in roomid - room name format.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- simple, raw viewer for rooms in the world
 
display(getRooms())
 
 
 
-- iterate over all rooms in code
 
for id,name in pairs(getRooms()) do
 
  print(id, name)
 
end
 
</syntaxhighlight>
 
  
==getRoomsByPosition==
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
;roomTable = getRoomsByPosition(areaID, x,y,z)
 
  
:Returns an indexed table of all rooms at the given coordinates in the given area, or an empty one if there are none. This function can be useful for checking if a room exists at certain coordinates, or whenever you have rooms overlapping.
+
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
 +
|}
  
{{note}} The returned table starts indexing from '''0''' and not the usual lua index of '''1''', which means that using '''#''' to count the size of the returned table will produce erroneous results - use [[Manual:Table_Functions#table.size|table.size()]] instead.
+
The addition of further texts would be subject to negotiation with the Mudlet Makers.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- sample alias to determine a room nearby, given a relative direction from the current room
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
 
+
function doLogin()
local otherroom
+
   if getCustomLoginTextId() ~= 1 then
if matches[2] == "" 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
  local w = matches[3]
+
     echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
  local ox, oy, oz, x,y,z = getRoomCoordinates(mmp.currentroom)
 
  local has = table.contains
 
   if has({"west", "left", "w", "l"}, w) then
 
    x = (x or ox) - 1; y = (y or oy); z = (z or oz)
 
  elseif has({"east", "right", "e", "r"}, w) then
 
     x = (x or ox) + 1; y = (y or oy); z = (z or oz)
 
  elseif has({"north", "top", "n", "t"}, w) then
 
    x = (x or ox); y = (y or oy) + 1; z = (z or oz)
 
  elseif has({"south", "bottom", "s", "b"}, w) then
 
    x = (x or ox); y = (y or oy) - 1; z = (z or oz)
 
  elseif has({"northwest", "topleft", "nw", "tl"}, w) then
 
    x = (x or ox) - 1; y = (y or oy) + 1; z = (z or oz)
 
  elseif has({"northeast", "topright", "ne", "tr"}, w) then
 
     x = (x or ox) + 1; y = (y or oy) + 1; z = (z or oz)
 
  elseif has({"southeast", "bottomright", "se", "br"}, w) then
 
    x = (x or ox) + 1; y = (y or oy) - 1; z = (z or oz)
 
  elseif has({"southwest", "bottomleft", "sw", "bl"}, w) then
 
    x = (x or ox) - 1; y = (y or oy) - 1; z = (z or oz)
 
  elseif has({"up", "u"}, w) then
 
    x = (x or ox); y = (y or oy); z = (z or oz) + 1
 
  elseif has({"down", "d"}, w) then
 
    x = (x or ox); y = (y or oy); z = (z or oz) - 1
 
  end
 
 
 
  local carea = getRoomArea(mmp.currentroom)
 
  if not carea then mmp.echo("Don't know what area are we in.") return end
 
 
 
  otherroom = select(2, next(getRoomsByPosition(carea,x,y,z)))
 
 
 
  if not otherroom then
 
    mmp.echo("There isn't a room to the "..w.." that I see - try with an exact room id.") return
 
 
   else
 
   else
     mmp.echo("The room "..w.." of us has an ID of "..otherroom)
+
     tempTime(2.0, [[sendCustomLoginText()]], 1)
 
   end
 
   end
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomUserData==
+
=Mudlet Object Functions=
;getRoomUserData(roomID, key)
+
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
  
:Returns the user data value (string) stored at a given room with a given key (string), or "" if none is stored. Use [[#setRoomUserData|setRoomUserData()]] function for setting the user data.
+
==ancestors, new in PR #6726==
 +
;ancestors(IDnumber, type)
 +
:You can use this function to find out about all the ancestors of something.
  
;Example
+
:Returns a list as a table with the details of each successively distance ancestor (if any) of the given item; the details are in the form of a sub-table, within each containing specifically:
<syntaxhighlight lang="lua">
+
:* its IDnumber as a number
display(getRoomUserData(341, "visitcount"))
+
:* its name as a string
</syntaxhighlight>
+
:* whether it is active as a boolean
 +
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)
 +
:Returns ''nil'' and an error message if either parameter is not valid
  
:;getRoomUserData(roomID, key, enableFullErrorReporting)
+
;Parameters
 
+
* ''IDnumber:''
::Returns the user data value (string) stored at a given room with a given key (string), or, if the boolean value ''enableFullErrorReporting'' is true, ''nil'' and an error message if the key is not present or the room does not exist; if ''enableFullErrorReporting'' is false an empty string is returned but then it is not possible to tell if that particular value is actually stored or not against the given key.
+
: The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.
  
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
+
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]
 
 
;Example
 
<!-- I would like this block to be indented to match the Example header but the mark-up system seems to be broken and only includes the first line
 
if the start of the code line begins: ":<lua>..."-->
 
<syntaxhighlight lang="lua">local vNum = 341
 
result, errMsg = getRoomUserData(vNum, "visitcount", true)
 
if result ~= nil then
 
    display(result)
 
else
 
    echo("\nNo visitcount data for room: "..vNum.."; reason: "..errMsg.."\n")
 
end</syntaxhighlight>
 
 
 
==getRoomUserDataKeys==
 
;getRoomUserDataKeys(roomID)
 
 
 
:Returns all the keys for user data items stored in the given room ID; will return an empty table if there is no data stored or nil if there is no such room with that ID. ''Can be useful if the user was not the one who put the data in the map in the first place!''
 
 
 
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getRoomUserDataKeys(3441))
+
-- To do
--might result in:--
 
{
 
  "description",
 
  "doorname_up",
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|3.0}}
+
==findItems, new in PR #6742==
 +
;findItems("name", "type"[, exact[, case sensitive]])
 +
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.
  
==getRoomWeight==
+
:Returns a list as a table with ids of each Mudlet item that matched or ''nil'' and an error message should an incorrect type string be given.
;getRoomWeight(roomID)
 
 
 
:Returns the weight of a room. By default, all new rooms have a weight of 1.
 
: See also: [[#setRoomWeight|setRoomWeight()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
display("Original weight of room 541: "..getRoomWeight(541))
 
setRoomWeight(541, 3)
 
display("New weight of room 541: "..getRoomWeight(541))
 
</syntaxhighlight>
 
 
 
==getSpecialExits==
 
;exits = getSpecialExits(roomID[, listAllExits])
 
  
 
;Parameters
 
;Parameters
* ''roomID:''
+
* ''name:''
: Room ID to return the special exits of.
+
:The name (as a string) of the item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
* ''listAllExits:''
+
* ''type:''
: (Since ''TBA'') In the case where there is more than one special exit to the same room ID list all of them.
+
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.
 
+
* ''exact:''
:Returns a roomid table of sub-tables containing name/command and exit lock status, of the special exits in the room. If there are no special exits in the room, the table returned will be empty.
+
:(Optional) a boolean which if omitted or ''true'' specifies to match the given name against the whole of the names for items or only as a sub-string of them. As a side effect, if this is provided and is ''false'' and an empty string (i.e. ''""'') is given as the first argument then the function will return the ID numbers of ''all'' items (both temporary and permanent) of the given type in existence at the time.
:Before ''TBA'' (likely to be Mudlet version '''4.11.0'''), if more than one special exit goes to the ''same'' exit room id then one of those exits is returned at random. Since ''TBA'' this will be the best (i.e. lowest-weight) exit that is '''not''' locked; should none be unlocked then the lowest locked one will be listed. In case of a tie, one of the tying exits will be picked at random.
+
* ''case sensitive:''
 
+
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.
: See also: [[#getRoomExits|getRoomExits()]]
 
  
 
;Example
 
;Example
<syntaxhighlight lang="lua">
+
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:
-- There are three special exits from 1337 to the room 42:
+
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]
-- "climb down ladder" which is locked and has an exit weight of 10
 
-- "step out window" which is unlocked and has an exit weight of 20
 
-- "jump out window" which is unlocked and has an exit weight of 990
 
getSpecialExits(1337)
 
 
 
-- In 4.10.1 and before this could results in:
 
table {
 
  42 = {"jump out window" = "0"},
 
  666 = {"dive into pit" = "1"}
 
}
 
-- OR
 
table {
 
  42 = {"climb down ladder" = "1"},
 
  666 = {"dive into pit" = "1"}
 
}
 
-- OR
 
table {
 
  42 = {"step out window" = "0"},
 
  666 = {"dive into pit" = "1"}
 
}
 
 
 
-- From TBA this will return:
 
table {
 
  42 = {"step out window" = "0"},
 
  666 = {"dive into pit" = "1"}
 
}
 
  
-- From TBA, with the second argument as true, this gives:
 
getSpecialExits(1337, true)
 
table {
 
  42 = {"step out window" = "0",
 
        "climb down ladder" = "1",
 
        "jump out window" = "0"},
 
  666 = {"dive into pit" = "1"}
 
}
 
</syntaxhighlight>
 
 
==getSpecialExitsSwap==
 
;getSpecialExitsSwap(roomID)
 
 
:Very similar to [[#getSpecialExits|getSpecialExits()]] function, but returns the rooms in the command - roomid style.
 
 
==gotoRoom==
 
;gotoRoom (roomID)
 
:Speedwalks you to the given room from your current room if it is able and knows the way. You must turn the map on for this to work, else it will return "(mapper): Don't know how to get there from here :(".
 
 
In case this isn't working, and you are coding your own mapping script, [[Manual:Mapper#Making_your_own_mapping_script|see here]] how to implement additional functionality necessary.
 
 
==hasExitLock==
 
;status = hasExitLock(roomID, direction)
 
 
:Returns ''true'' or ''false'' depending on whenever a given exit leading out from a room is locked. Direction can be specified as a number, short direction name ("nw") or long direction name ("northwest").
 
 
; Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- check if the east exit of room 1201 is locked
+
-- Should find just the package with the name:
display(hasExitLock(1201, 4))
+
lua findItems("echo", "alias")
display(hasExitLock(1201, "e"))
+
{ 3 }
display(hasExitLock(1201, "east"))
 
</syntaxhighlight>
 
  
: See also: [[#lockExit|lockExit()]]
+
-- Should find both the package and the alias - as the latter contains "echo" with another character
 +
lua findItems("echo", "alias", false)
 +
{ 3, 4 }
  
==hasSpecialExitLock==
+
-- Finds the ID numbers of all the aliases:
;hasSpecialExitLock(from roomID, to roomID, moveCommand)
+
lua findItems("", "alias", false)
 +
{ 1, 2, 3, 4, 5, 6, 7 }
  
:Returns ''true'' or ''false'' depending on whenever a given exit leading out from a room is locked. ''moveCommand'' is the action to take to get through the gate.
+
-- Will still find the package with the name "echo" as we are not concerned with the casing now:
 +
lua findItems("Echo", "alias", true, false)
 +
{ 3 }
  
See also: [[#lockSpecialExit|lockSpecialExit()]]
+
-- Won't find the package with the name "echo" now as we are concerned with the casing:
 
+
lua findItems("Echo", "alias", true, true)
<syntaxhighlight lang="lua">
+
{}
-- lock a special exit from 17463 to 7814 that uses the 'enter feather' command
 
lockSpecialExit(17463, 7814, 'enter feather', true)
 
 
 
-- see if it is locked: it will say 'true', it is
 
display(hasSpecialExitLock(17463, 7814, 'enter feather'))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==highlightRoom==
+
==isActive, modified by PR #6726==
;highlightRoom( roomID, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)
+
;isActive(name/IDnumber, type[, checkAncestors])
 +
:You can use this function to check if something, or somethings, are active.
  
:Highlights a room with the given color, which will override its environment color. If you use two different colors, then there'll be a shading from the center going outwards that changes into the other color.  
+
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
  
 
;Parameters
 
;Parameters
* ''roomID''
+
* ''name:''
: ID of the room to be colored.
+
:The name (as a string) or, from '''Mudlet 4.17.0''', the ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
* ''color1Red, color1Green, color1Blue''
+
* ''type:''
: RGB values of the first color.
+
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').
* ''color2Red, color2Green, color2Blue''
+
* ''checkAncestors:''
: RGB values of the second color.
+
:(Optional) If provided AND ''true'' (considered ''false'' if absent to reproduce behavior of previous versions of Mudlet) then this function will only count an item as active if it '''and''' all its parents (ancestors) are active (from '''Mudlet tbd''').
* ''highlightRadius''  
 
: The radius for the highlight circle - if you don't want rooms beside each other to overlap, use ''1'' as the radius.
 
* ''color1Alpha'' and ''color2Alpha''
 
: Transparency values from 0 (completely transparent) to 255 (not transparent at all).
 
  
: See also: [[#unHighlightRoom|unHighlightRoom()]]
+
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]
 
 
<syntaxhighlight lang="lua">
 
-- color room #351 red to blue
 
local r,g,b = unpack(color_table.red)
 
local br,bg,bb = unpack(color_table.blue)
 
highlightRoom(351, r,g,b,br,bg,bb, 1, 255, 255)
 
</syntaxhighlight>
 
 
 
==killMapInfo==
 
;killMapInfo(label)
 
 
 
Delete a map info contributor entirely - it will be not available anymore.
 
 
 
;Parameters
 
* ''label:''
 
: Name under which map info to be removed was registered.
 
 
 
: See also: [[#registerMapInfo|registerMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#disableMapInfo|disableMapInfo()]]
 
 
 
{{MudletVersion|4.11}}
 
 
 
==loadJsonMap==
 
; loadJsonMap(pathFileName)
 
 
 
; Parameters:
 
 
 
* ''pathFileName'' a string that is an absolute path and file name to read the data from.
 
 
 
Load the Mudlet map in text (JSON) format. It does take longer than loading usual map file (''.dat'' in binary) so it will show a progress dialog.
 
 
 
: See also: [[#saveJsonMap|saveJsonMap()]]
 
 
 
Returns:
 
* ''true'' on success
 
* ''nil'' and an error message on failure.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
loadJsonMap(getMudletHomeDir() .. "/map.json")
+
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")
  
true
+
-- Can also be used to check if a specific item is enabled or not.
 +
if isActive("spellname", "trigger") > 0 then
 +
  -- the spellname trigger is active
 +
else
 +
  -- it is not active
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.11.0}}
+
{{note}} A positive ID number that does not exist will still return a ''0'' value, this is for constancy with the way the function behaves for a name that does not refer to any item either. If necessary the existence of an item should be confirmed with [[#exists|exists(...)]] first.
  
==loadMap==
+
==isAncestorsActive, new in PR #6726==
;loadMap(file location)
+
;isAncestorsActive(IDnumber, "type")
 +
:You can use this function to check if '''all''' the ancestors of something are active independent of whether it itself is, (for that use the two argument form of [[#isActive|isActive(...)]]).
  
:Loads the map file from a given location. The map file must be in Mudlet's format - saved with [[#saveMap|saveMap()]] or, as of the Mudlet 3.0 may be a MMP XML map conforming to the structure used by I.R.E. for their downloadable maps for their MUD games.  
+
:Returns ''true'' if all (if any) of the ancestors of the item with the specified ID number and type are active, if there are no such parents then it will also returns ''true''; otherwise returns ''false''. In the event that an invalid type string or item number is provided returns ''nil'' and an error message.
  
:Returns a boolean for whenever the loading succeeded. Note that the mapper must be open, or this will fail.
+
;Parameters
 
+
* ''IDnumber:''
:Using no arguments will load the last saved map.
+
:The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
  
<syntaxhighlight lang="lua">
+
:See also: [[#exists|exists(...)]]
  loadMap("/home/user/Desktop/Mudlet Map.dat")
 
</syntaxhighlight>
 
 
 
{{Note}} A file name ending with <code>.xml</code> will indicate the XML format.
 
 
 
==lockExit==
 
;lockExit(roomID, direction, lockIfTrue)
 
 
 
:Locks a given exit from a room. The destination may remain accessible through other paths, unlike [[#lockRoom|lockRoom]]. Direction can be specified as a number, short direction name ("nw") or long direction name ("northwest").
 
 
 
: See also: [[#hasExitLock|hasExitLock()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- lock the east exit of room 1201 so we never path through it
+
-- To do
lockExit(1201, 4, true)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==lockRoom==
+
=Networking Functions=
;lockRoom (roomID, lockIfTrue)
+
:A collection of functions for managing networking.
 
+
==sendSocket revised in PR #7066 (Open)==
:Locks a given room id from future speed walks (thus the mapper will never path through that room).
 
: See also: [[#roomLocked | roomLocked()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
lockRoom(1, true) -- locks a room if from being walked through when speedwalking.
 
lockRoom(1, false) -- unlocks the room, adding it back to possible rooms that can be walked through.
 
</syntaxhighlight>
 
 
 
==lockSpecialExit==
 
;lockSpecialExit (from roomID, to roomID, special exit command, lockIfTrue)
 
 
 
:Locks a given special exit, leading from one specific room to another that uses a certain command from future speed walks (thus the mapper will never path through that special exit).
 
: See also: [[#hasSpecialExitLock | hasSpecialExitLock()]], [[#lockExit | lockExit()]], [[#lockRoom | lockRoom()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
lockSpecialExit(1,2,'enter gate', true) -- locks the special exit that does 'enter gate' to get from room 1 to room 2
 
lockSpecialExit(1,2,'enter gate', false) -- unlocks the said exit
 
</syntaxhighlight>
 
  
==mapSymbolFontInfo==
+
;sendSocket(data)
  
;mapSymbolFontInfo()
+
:Sends given binary data as-is (or with some predefined special tokens converted to byte values) to the game. You can use this to implement support for a [[Manual:Supported_Protocols#Adding_support_for_a_telnet_protocol|new telnet protocol]], [http://forums.mudlet.org/viewtopic.php?f=5&t=2272 simultronics] [http://forums.mudlet.org/viewtopic.php?f=5&t=2213#p9810 login] etc.
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
 
  
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
+
; success = sendSocket("data")
  
;returns
+
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]
* 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}} Modified in Mudlet '''tbd''' to accept some tokens like "''<NUL>''" to include byte values that are not possible to insert with the standard Lua string escape "''\###''" form where ### is a three digit number between 000 and 255 inclusive or where the value is more easily provided via a mnemonic. For the table of the tokens that are known about, see the one in [[Manual:Lua_Functions#feedTelnet|feedTelnet()]].
  
==moveMapLabel==
+
{{note}} The data (as bytes) once the tokens have been converted to their byte values is sent as is to the Game Server; any encoding to, say, a UTF-8 representation or to duplicate ''0xff'' byte values so they are not considered to be Telnet ''<IAC>'' (Interpret As Command) bytes must be done to the data prior to calling this function.
 
 
;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
* ''areaID/Name:''
+
* ''data:''
: Area ID as number or AreaName as string containing the map label.
+
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.
  
* ''labelID/Text:''
+
;Returns
: 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.
+
* (Only since Mudlet '''tbd''') Boolean ''true'' if the whole data string (after token replacement) was sent to the Server, ''false'' if that failed for any reason (including if the Server has not been connected or is now disconnected). ''nil'' and an error message for any other defect.
 
 
* ''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">
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
+
-- Tell the Server that we are now willing and able to process  to process Ask the Server to a comment explaining what is going on, if there is multiple functionalities (or optional parameters) the examples should start simple and progress in complexity if needed!
moveMapLabel(0, 2, 3.0, 4.0)
+
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
 +
-- comments up top should introduce / explain what it does
  
-- 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
+
local something = function(exampleValue)
moveMapLabel(0, 2, -1.0, 0.0, false)
+
if something then
 
+
  -- do something with something (assuming there is a meaningful return value)
-- 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**:
+
end
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
+
-- maybe another example for the optional second case
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
+
local somethingElse = function(exampleValue, anotherValue)
  
-- 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:
+
-- lastly, include an example with error handling to give an idea of good practice
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)
+
local ok, err = function()
 
 
-- all of the above will return the 'true'  boolean value assuming there are the indicated labels and areas
 
</syntaxhighlight>
 
 
 
==moveMapWidget==
 
;moveMapWidget(Xpos, Ypos)
 
:moves the map window to the given position.
 
: See also: [[#openMapWidget|openMapWidget()]], [[#closeMapWidget|closeMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
 
 
 
;Parameters
 
* ''Xpos:''
 
: X position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
 
* ''Ypos:''
 
: Y position of the map window. Measured in pixels, with 0 being the very top. Passed as an integer number.
 
 
 
{{MudletVersion|4.7}}
 
 
 
==openMapWidget==
 
;openMapWidget([dockingArea | Xpos, Ypos, width, height])
 
means either of these are fine:
 
;openMapWidget()
 
;openMapWidget(dockingArea)
 
;openMapWidget(Xpos, Ypos, width, height)
 
 
 
:opens a map window with given options.
 
 
 
: See also: [[#closeMapWidget|closeMapWidget()]], [[#moveMapWidget|moveMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
 
 
 
{{MudletVersion|4.7}}
 
 
 
;Parameters
 
{{note}} If no parameter is given the map window will be opened with the saved layout or at the right docking position (similar to clicking the icon)
 
* ''dockingArea:''
 
: If only one parameter is given this parameter will be a string that contains one of the possible docking areas the map window will be created in (f" floating "t" top "b" bottom "r" right and "l" left)
 
{{note}} If 4 parameters are given the map window will be created in floating state
 
* ''Xpos:''
 
: X position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
 
* ''Ypos:''
 
: Y position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
 
* ''width:''
 
: The width map window, in pixels. Passed as an integer number.
 
* ''height:''
 
: The height map window, in pixels. Passed as an integer number.
 
 
 
==pauseSpeedwalk==
 
;pauseSpeedwalk()
 
 
 
:Pauses a speedwalk started using [[#speedwalk|speedwalk()]]
 
 
 
: See also: [[#speedwalk|speedwalk()]], [[#stopSpeedwalk|stopSpeedwalk()]], [[#resumeSpeedwalk|resumeSpeedwalk()]]
 
 
 
{{MudletVersion|4.13}}
 
 
 
<syntaxhighlight lang="lua">
 
local ok, err = pauseSpeedwalk()
 
 
if not ok then
 
if not ok then
   debugc(f"Error: unable to pause speedwalk because {err}\n")
+
   debugc(f"Error: unable to do <particular thing> because {err}\n")
 
   return
 
   return
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==registerMapInfo==
+
; Additional development notes
;registerMapInfo(label, function)
+
-- This function is still being written up.
  
Adds an extra 'map info' to the mapper widget which can be used to display custom information.
+
==feedTelnet added in PR #7066 (Open)====
  
: See also: [[#killMapInfo|killMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#disableMapInfo|disableMapInfo()]]
+
; feedTelnet(data)
  
{{MudletVersion|4.11}}
+
:Sends given binary data with some predefined special tokens converted to byte values, to the internal telnet engine, as if it had been received from the game. This is primarily to enable testing when new Telnet sub-options/protocols are being developed. The data has to be injected into the system nearer to the point where the Game Server's data starts out than ''feedTriggers()'' and unlike the latter the data is not subject to any encoding so as to match the current profile's setting (which normally happens with ''feedTriggers()''). Furthermore - to prevent this function from putting the telnet engine into a state which could damage the processing of real game data it will refuse to work unless the Profile is completely disconnected from the game server.
  
{{note}}
+
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]
You can register multiple map infos - just give them unique names and toggle whichever ones you need.
 
  
;Parameters
+
{{MudletVersion|tbd}}
* ''label:''
 
: Name under which map info will be registered and visible in select box under mapper. You can use it later to kill map info, enable it, disable it or overwrite using [[#registerMapInfo|registerMapInfo()]] again.
 
* ''function:''
 
: Callback function that will be responsible for returning information how to draw map info fragment.
 
  
Callback function is called with following arguments:
+
{{note}} This is not really intended for end-user's but might be useful in some circumstances.
* ''roomId'' - current roomId or currently selected room (when multiple selection is made this is center room)
 
* ''selectionSize'' -  how many rooms are selected
 
* ''areaId'' - roomId's areaId
 
* ''displayedAreaId'' - areaId that is currently displayed
 
  
Callback needs to return following:
+
;Parameters
* ''text'' - text that will be displayed (when empty, nothing will be displayed, if you want to "reserve" line or lines use not empty value " " or add line breaks "\n")
+
* ''data''
* ''isBold'' (optional) -  true/false - determines whether text will be bold
+
: String containing the bytes to send to the internal telnet engine as if it had come from the Game Server, it can containing some tokens listed below that are to be converted to bytes as well.
* ''isItalic'' (optional) - true/false - determines whether text will be italic
 
* ''color r'' (optional) - color of text red component (0-255)
 
* ''color g'' (optional) - color of text green component (0-255)
 
* ''color b'' (optional) - color of text blue component (0-255)
 
  
{{note}}
+
;Returns
Map info is registered in disabled state, you need to enable it through script or by selecting checkbox under mapper.
+
* Boolean ''true'' if the ''data'' string was sent to the internal telnet engine. ''nil'' and an error message otherwise, specifically the case when there is some traces of a connection or a complete connection to the socket that passes the data to and from the game server. Additionally, if the data is an empty string ''""'' a second return value will be provided as an integer number representing a version for the table of tokens - which will be incremented each time a change is made to that table so that which tokens are valid can be determined. Note that unrecognised tokens should be passed through as is and not get replaced.
  
<syntaxhighlight lang="lua">
+
{| class="wikitable sortable"
registerMapInfo("My very own handler!", function(roomId, selectionSize, areaId, displayedArea)
+
|+ Token value table
  return string.format("RoomId: %d\nNumbers of room selected: %d\nAreaId: %d\nDisplaying area: %d", roomId, selectionSize, areaId, displayedArea),
+
|-
  true, true, 0, 255, 0
+
! Token !! Byte !! Version!! Notes
end)
+
|-
enableMapInfo("My very own handler!")
+
|| <00> || \0x00 || 1 || 0 dec.
</syntaxhighlight>
+
|-
 +
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary
 +
|-
 +
|| <NUL> || \0x00 || 1 || ASCII control character: NULL
 +
|-
 +
|| <01> || \x01 || 1 || 1 dec.
 +
|-
 +
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo
 +
|-
 +
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading
 +
|-
 +
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect
 +
|-
 +
|| <STX> || \x02 || 1 || ASCII control character: Start of Text
 +
|-
 +
|| <03> || \x03 || 1 || 3 dec.
 +
|-
 +
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead
 +
|-
 +
|| <ETX> || \x03 || 1 || ASCII control character: End of Text
 +
|-
 +
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation
 +
|-
 +
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission
 +
|-
 +
|| <05> || \x05 || 1 ||
 +
|-
 +
|| <O_STATUS> || \x05 || 1 ||
 +
|-
 +
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry
 +
|-
 +
|| <06> || \x06 || 1 || Telnet option: Timing Mark
 +
|-
 +
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge
 +
|-
 +
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo
 +
|-
 +
|| <BELL> || \x07 || 1 || ASCII control character: Bell
 +
|-
 +
|| <08> || \x08 || 1 || Telnet option: Output Line Width
 +
|-
 +
|| <BS> || \x08 || 1 ||
 +
|-
 +
|| <09> || \x09 || 1 || Telnet option: Output Page Size
 +
|-
 +
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab
 +
|-
 +
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition
 +
|-
 +
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed
 +
|-
 +
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops
 +
|-
 +
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab
 +
|-
 +
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition
 +
|-
 +
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed
 +
|-
 +
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition
 +
|-
 +
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return
 +
|-
 +
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops
 +
|-
 +
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out
 +
|-
 +
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition
 +
|-
 +
|| <SI> || \x0f || 1 || ASCII control character: Shift-In
 +
|-
 +
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition
 +
|-
 +
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape
 +
|-
 +
|| <11> || \x11 || 1 || Telnet option: Extended ASCII
 +
|-
 +
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1
 +
|-
 +
|| <12> || \x12 || 1 || Telnet option: Logout
 +
|-
 +
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2
 +
|-
 +
|| <13> || \x13 || 1 || Telnet option: Byte Macro
 +
|-
 +
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3
 +
|-
 +
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal
 +
|-
 +
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4
 +
|-
 +
|| <15> || \x15 || 1 || Telnet option: SUPDUP
 +
|-
 +
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge
 +
|-
 +
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output
 +
|-
 +
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle
 +
|-
 +
|| <17> || \x17 || 1 || Telnet option: Send location
 +
|-
 +
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block
 +
|-
 +
|| <18> || \x18 || 1 ||
 +
|-
 +
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type
 +
|-
 +
|| <CAN> || \x18 || 1 || ASCII control character: Cancel
 +
|-
 +
|| <19> || \x19 || 1 ||
 +
|-
 +
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record
 +
|-
 +
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium
 +
|-
 +
|| <1A> || \x1a || 1 || Telnet option:  TACACS User Identification
 +
|-
 +
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute
 +
|-
 +
|| <1B> || \x1b || 1 || Telnet option: Output Marking
 +
|-
 +
|| <ESC> || \x1b || 1 || ASCII control character: Escape
 +
|-
 +
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number
 +
|-
 +
|| <FS> || \x1c || 1 || ASCII control character: File Separator
 +
|-
 +
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime
 +
|-
 +
|| <GS> || \x1d || 1 || ASCII control character: Group Separator
 +
|-
 +
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD
 +
|-
 +
|| <RS> || \x1e || 1 || ASCII control character: Record Separator
 +
|-
 +
|| <1F> || \x1f || 1 ||
 +
|-
 +
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size
 +
|-
 +
|| <US> || \x1f || 1 || ASCII control character: Unit Separator
 +
|-
 +
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space
 +
|-
 +
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)
 +
|-
 +
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set
 +
|-
 +
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit
 +
|-
 +
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol
 +
|-
 +
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol
 +
|-
 +
|| <O_MCCP> || \x55 || 1 || 85 dec
 +
|-
 +
|| <O_MCCP2> || \x56 || 1 || 86 dec
 +
|-
 +
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol
 +
|-
 +
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol
 +
|-
 +
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol
 +
|-
 +
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol
 +
|-
 +
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete
 +
|-
 +
|| <O_ATCP> || \xc8 || 1 || 200 dec
 +
|-
 +
|| <O_GMCP> || \xc9 || 1 || 201 dec
 +
|-
 +
|| <T_EOR> || \xef || 1 || 239 dec
 +
|-
 +
|| <F0> || \xf0 || 1 ||
 +
|-
 +
|| <T_SE> || \xf0 || 1 ||
 +
|-
 +
|| <F1> || \xf1 || 1 ||
 +
|-
 +
|| <T_NOP> || \xf1 || 1 ||
 +
|-
 +
|| <F2> || \xf2 || 1 ||
 +
|-
 +
|| <T_DM> || \xf2 || 1 ||
 +
|-
 +
|| <F3> || \xf3 || 1 ||
 +
|-
 +
|| <T_BRK> || \xf3 || 1 ||
 +
|-
 +
|| <F4> || \xf4 || 1 ||
 +
|-
 +
|| <T_IP> || \xf4 || 1 ||
 +
|-
 +
|| <F5> || \xf5 || 1 ||
 +
|-
 +
|| <T_ABOP> || \xf5 || 1 ||
 +
|-
 +
|| <F6> || \xf6 || 1 ||
 +
|-
 +
|| <T_AYT> || \xf6 || 1 ||
 +
|-
 +
|| <F7> || \xf7 || 1 ||
 +
|-
 +
|| <T_EC> || \xf7 || 1 ||
 +
|-
 +
|| <F8> || \xf8 || 1 ||
 +
|-
 +
|| <T_EL> || \xf8 || 1 ||
 +
|-
 +
|| <F9> || \xf9 || 1 ||
 +
|-
 +
|| <T_GA> || \xf9 || 1 ||
 +
|-
 +
|| <FA> || \xfa || 1 ||
 +
|-
 +
|| <T_SB> || \xfa || 1 ||
 +
|-
 +
|| <FB> || \xfb || 1 ||
 +
|-
 +
|| <T_WILL> || \xfb || 1 ||
 +
|-
 +
|| <FC> || \xfc || 1 ||
 +
|-
 +
|| <T_WONT> || \xfc || 1 ||
 +
|-
 +
|| <FD> || \xfd || 1 ||
 +
|-
 +
|| <T_DO> || \xfd || 1 ||
 +
|-
 +
|| <FE> || \xfe || 1 ||
 +
|-
 +
|| <T_DONT> || \xfe || 1 ||
 +
|-
 +
|| <FF> || \xff || 1 ||
 +
|-
 +
|| <T_IAC> || \xff'
 +
|}
  
Example will display something like that:
+
;Example
 
 
[[File:Map-info-example.png]]
 
 
 
Using function arguments is completely optional and you can determine whether and how to display map info completely externally.
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
registerMapInfo("Alert", function()  
+
-- a comment explaining what is going on, if there is multiple functionalities (or optional parameters) the examples should start simple and progress in complexity if needed!
  if character.hp < 20 then
+
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
    return "Look out! Your HP is getting low", true, false, unpack(color_table.red) -- will display red, bolded warning whne character.hp is below 20
+
-- comments up top should introduce / explain what it does
  else
 
    return "" -- will not return anything
 
  end
 
end)
 
enableMapInfo("Alert")
 
</syntaxhighlight>
 
  
==resumeSpeedwalk==
+
local something = feedTelnet(exampleValue)
;resumeSpeedwalk()
+
if something then
 
+
  -- do something with something (assuming there is a meaningful return value)
:Continues a speedwalk paused using [[#pauseSpeedwalk|pauseSpeedwalk()]]
+
end
: See also: [[#speedwalk|speedwalk()]], [[#pauseSpeedwalk|pauseSpeedwalk()]], [[#stopSpeedwalk|stopSpeedwalk()]]
 
  
{{MudletVersion|4.13}}
+
-- maybe another example for the optional second case
 +
local somethingElse = function(exampleValue, anotherValue)
  
<syntaxhighlight lang="lua">
+
-- lastly, include an example with error handling to give an idea of good practice
local ok, err = resumeSpeedwalk()
+
local ok, err = function()
 
if not ok then
 
if not ok then
   cecho(f"\n<red>Error:<reset> Problem resuming speedwalk: {err}\n")
+
   debugc(f"Error: unable to do <particular thing> because {err}\n")
 
   return
 
   return
 
end
 
end
cecho("\n<green>Successfully resumed speedwalk!\n")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==removeCustomLine==
+
; Additional development notes
;removeCustomLine(roomID, direction)
+
-- This function is still being written up.
  
:Removes the custom exit line that's associated with a specific exit of a room.
+
=String Functions=
:See also: [[#addCustomLine|addCustomLine()]], [[#getCustomLines|getCustomLines()]]
+
:These functions are used to manipulate strings.
  
;Example
+
=Table Functions=
<syntaxhighlight lang="lua">
+
: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.
-- remove custom exit line that starts in room 315 going north
 
removeCustomLine(315, "n")
 
</syntaxhighlight>
 
  
==removeMapEvent==
+
=Text to Speech Functions=
;removeMapEvent(event name)
+
: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.
  
:Removes the given menu entry from a mappers right-click menu. You can add custom ones with [[#addMapEvent | addMapEvent()]].
+
=UI Functions=
: See also: [[#addMapEvent | addMapEvent()]], [[#getMapEvents | getMapEvents()]], [[#removeMapMenu | removeMapMenu()]]
+
: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.
  
;Example
+
==cecho2decho PR#6849 merged==
<syntaxhighlight lang="lua">
+
; convertedString = cecho2decho(str)
addMapEvent("room a", "onFavorite") -- add one to the general menu
 
removeMapEvent("room a") -- removes the said menu
 
</syntaxhighlight>
 
  
==removeMapMenu==
+
:Converts a cecho formatted string to a decho formatted one.
;removeMapMenu(menu name)
+
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
  
:Removes the given submenu from a mappers right-click menu. You can add custom ones with [[#addMapMenu | addMapMenu()]].
+
{{MudletVersion|4.18}}
: See also: [[#addMapMenu | addMapMenu()]], [[#getMapMenus | getMapMenus()]], [[#removeMapEvent | removeMapEvent()]]
 
  
;Example
+
;Parameters
<syntaxhighlight lang="lua">
+
* ''str''
addMapMenu("Test") -- add submenu to the general menu
+
: string you wish to convert from cecho to decho
removeMapMenu("Test") -- removes that same menu again
+
;Returns
</syntaxhighlight>
+
* a string formatted for decho
 
 
==removeSpecialExit==
 
;removeSpecialExit(roomID, command)
 
 
 
:Removes the special exit which is accessed by ''command'' from the room with the given ''roomID''.
 
:See also: [[#addSpecialExit|addSpecialExit()]], [[#clearSpecialExits|clearSpecialExits()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
addSpecialExit(1, 2, "pull rope") -- add a special exit from room 1 to room 2
+
-- convert to a decho string and use decho to display it
removeSpecialExit(1, "pull rope") -- removes the exit again
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
decho(cecho2decho(cechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==resetRoomArea==
+
==cecho2hecho PR#6849 merged==
;resetRoomArea (roomID)
+
; convertedString = cecho2hecho(str)
 
 
: Unassigns the room from its given area. While not assigned, its area ID will be -1.  Note that since Mudlet 3.0 the "default area" which has the id of -1 may be selectable in the area selection widget on the mapper - although there is also an option to conceal this in the settings.
 
 
 
: See also: [[#setRoomArea | setRoomArea()]], [[#getRoomArea | getRoomArea()]]
 
  
;Example
+
:Converts a cecho formatted string to an hecho formatted one.
<syntaxhighlight lang="lua">
+
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
resetRoomArea(3143)
 
</syntaxhighlight>
 
  
==resizeMapWidget==
+
{{MudletVersion|4.18}}
;resizeMapWidget(width, height)
 
:resizes a map window with given width, height.
 
: See also: [[#openMapWidget|openMapWidget()]], [[#closeMapWidget|closeMapWidget()]], [[#moveMapWidget|moveMapWidget()]]
 
 
 
{{MudletVersion|4.7}}
 
  
 
;Parameters
 
;Parameters
* ''width:''
+
* ''str''
: The width of the map window, in pixels. Passed as an integer number.
+
: string you wish to convert from cecho to decho
* ''height:''
+
;Returns  
: The height of the map window, in pixels. Passed as an integer number.
+
* a string formatted for hecho
 
 
==roomExists==
 
;roomExists(roomID)
 
 
 
:Returns a boolean true/false depending if the room with that ID exists (is created) or not.
 
 
 
==roomLocked==
 
;locked = roomLocked(roomID)
 
 
 
:Returns true or false whenever a given room is locked.
 
: See also: [[#lockRoom|lockRoom()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
echo(string.format("Is room #4545 locked? %s.", roomLocked(4545) and "Yep" or "Nope"))
+
-- convert to an hecho string and use hecho to display it
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
hecho(cecho2hecho(cechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==saveJsonMap==
+
==cecho2html PR#6849 merged==
; saveJsonMap([pathFileName])
+
; convertedString = cecho2html(str[, resetFormat])
Saves all the data that is normally held in the Mudlet map (''.dat'' as a binary format) in text (JSON) format. It does take longer to do this, so a progress dialog will be shown indicating the status.
 
 
 
: See also: [[#loadJsonMap|loadJsonMap()]]
 
{{MudletVersion|4.11.0}}
 
  
; Parameters:
+
:Converts a cecho formatted string to an html formatted one.
* ''pathFileName'' (optional in Mudlet 4.12+): a string that is an absolute path and file name to save the data into.
+
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]
  
; Returns:
+
{{MudletVersion|4.18}}
* ''true'' on success
 
* ''nil'' and an error message on failure.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
saveJsonMap(getMudletHomeDir() .. "/map.json")
 
 
 
true
 
</syntaxhighlight>
 
 
 
==saveMap==
 
;saveMap([location], [version])
 
 
 
:Saves the map to a given location, and returns true on success. The location folder needs to be already created for save to work. You can also save the map in the Mapper settings tab.
 
  
 
;Parameters
 
;Parameters
* ''location''
+
* ''str''
: (optional) save the map to the given location if provided, or the default one otherwise.
+
: string you wish to convert from cecho to decho
* ''version''
+
* ''resetFormat''
: (optional) map version as a number to use when saving (Mudlet 3.17+)
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 
+
;Returns
: See also: [[#loadMap|loadMap()]]
+
* a string formatted for html
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local savedok = saveMap(getMudletHomeDir().."/my fancy map.dat")
+
-- create the base string
if not savedok then
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
  echo("Couldn't save :(\n")
 
else
 
  echo("Saved fine!\n")
 
end
 
 
 
-- save with a particular map version
 
saveMap(20)
 
</syntaxhighlight>
 
  
==searchAreaUserData==
+
-- create a label to display the result onto
;searchAreaUserData(area number | area name[, case-sensitive [, exact-match]])
+
testLabel = Geyser.Label:new({name = "testLabel"})
:Searches Areas' User Data in a manner exactly the same as [[#searchRoomUserData|searchRoomUserData()]] does in all Rooms' User Data, refer to that command for the specific details except to replace references to rooms and room ID numbers there with areas and areas ID numbers.
 
  
==searchRoom==
+
-- convert the cecho string to an html one, using the default formatting of testLabel created above
;searchRoom (room number | room name[, case-sensitive [, exact-match]])
+
local htmlString = cecho2html(cechoString, testLabel:getFormat())
:Searches for rooms that match (by case-insensitive, substring match) the given room name. It returns a key-value table in form of ''roomid = roomname'', the optional second and third boolean parameters have been available since Mudlet 3.0;
 
  
::If no rooms are found, then an empty table is returned.
+
-- and finally echo it to the label to see
 
+
-- I use rawEcho as that displays the html exactly as given.
:If you pass it a '''number''' instead of a '''string''' as just one argument, it'll act like [[#getRoomName|getRoomName()]] and return the room name.
+
testLabel:rawEcho(htmlString)
 
 
;Examples
 
<syntaxhighlight lang="lua">
 
-- show the behavior when given a room number:
 
display(searchRoom(3088))
 
"The North Road South of Taren Ferry"
 
 
 
-- show the behavior when given a string:
 
-- shows all rooms containing the text in any case:
 
display(searchRoom("North road"))
 
{
 
  [3114] = "Bend in North road",
 
  [3115] = "North road",
 
  [3116] = "North Road",
 
  [3117] = "North road",
 
  [3146] = "Bend in the North Road",
 
  [3088] = "The North Road South of Taren Ferry",
 
  [6229] = "Grassy Field By North Road"
 
}
 
-- or:
 
--  display(searchRoom("North road",false))
 
--  display(searchRoom("North road",false,false))
 
-- would both also produce those results.
 
 
 
-- shows all rooms containing the text in ONLY the letter-case provided:
 
display(searchRoom("North road",true,false))
 
{
 
  [3114] = "Bend in North road",
 
  [3115] = "North road",
 
  [3117] = "North road",
 
}
 
 
 
-- shows all rooms containing ONLY that text in either letter-case:
 
lua searchRoom("North road",false,true)
 
{
 
  [3115] = "North road",
 
  [3116] = "North Road",
 
  [3117] = "North road"
 
}
 
 
 
-- shows all rooms containing only and exactly the given text:
 
lua searchRoom("North road",true,true)
 
{
 
  [3115] = "North road",
 
  [3117] = "North road"
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
{{note}} Technically, with both options (case-sensitive and exact-match) set to true, one could just return a list of numbers as we know precisely what the string will be, but it was kept the same for maximum flexibility in user scripts.
 
  
==searchRoomUserData==  
+
==decho2cecho PR#6849 merged==
;searchRoomUserData([key, [value]])
+
; convertedString = decho2cecho(str)
:A command with three variants that search though all the rooms in sequence (so '''not as fast as a user built/maintained ''index'' system''') and find/reports on the room user data stored:
 
  
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#setRoomUserData|setRoomUserData()]]
+
:Converts a decho formatted string to a cecho formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
  
;searchRoomUserData(key, value)
+
{{MudletVersion|4.18}}
  
:Reports a (sorted) list of all room ids with user data with the given "value" for the given (case sensitive) "key".
+
;Parameters
 
+
* ''str''
;searchRoomUserData(key)
+
: string you wish to convert from decho to cecho
 
+
;Returns
:Reports a (sorted) list of the unique values from all rooms with user data with the given (case sensitive) "key".
+
* a string formatted for cecho
 
 
;searchRoomUserData()
 
 
 
:Reports a (sorted) list of the unique keys from all rooms with user data with any (case sensitive) "key", available since Mudlet 3.0. It is possible (though not recommended) to have a room user data item with an empty string "" as a key, this is handled correctly.
 
 
 
{{MudletVersion|3.0}}
 
 
 
;Examples
 
<syntaxhighlight lang="lua">
 
-- if I had stored the details of "named doors" as part of the room user data --
 
display(searchRoomUserData("doorname_up"))
 
 
 
--[[ could result in a list:
 
{
 
  "Eastgate",
 
  "Northgate",
 
  "boulderdoor",
 
  "chamberdoor",
 
  "dirt",
 
  "floorboards",
 
  "floortrap",
 
  "grate",
 
  "irongrate",
 
  "rockwall",
 
  "tomb",
 
  "trap",
 
  "trapdoor"
 
}]]
 
 
 
-- then taking one of these keys --
 
display(searchRoomUserData("doorname_up","trapdoor"))
 
 
 
--[[ might result in a list:
 
{
 
  3441,
 
  6113,
 
  6115,
 
  8890
 
}
 
]]</syntaxhighlight>
 
 
 
==setAreaName==
 
;setAreaName(areaID or areaName, newName)
 
 
 
:Names, or renames an existing area to the new name. The area must be created first with [[#addAreaName|addAreaName()]] and it must be unique.
 
 
 
{{note}} parameter areaName is available since Mudlet 3.0.
 
 
 
:See also: [[#deleteArea|deleteArea()]], [[#addAreaName|addAreaName()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setAreaName(2, "My city")
+
-- convert to a decho string and use cecho to display it
 
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
-- available since Mudlet 3.0
+
cecho(decho2cecho(dechoString))
setAreaName("My old city name", "My new city name")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setAreaUserData==
+
==decho2hecho PR#6849 merged==
;setAreaUserData(areaID, key (as a string), value (as a string))
+
; convertedString = decho2hecho(str)
  
:Stores information about an area under a given key. Similar to Lua's key-value tables, except only strings may be used here. One advantage of using userdata is that it's stored within the map file itself - so sharing the map with someone else will pass on the user data. Returns a lua ''true'' value on success. You can have as many keys as you'd like, however a blank key will not be accepted and will produce a lua ''nil'' and an error message instead.
+
:Converts a decho formatted string to an hecho formatted one.  
 +
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
  
:Returns true if successfully set.
+
{{MudletVersion|4.18}}
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#getAreaUserData|getAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]]
 
  
{{MudletVersion|3.0}}
+
;Parameters
 +
* ''str''
 +
: string you wish to convert from decho to decho
 +
;Returns
 +
* a string formatted for hecho
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- can use it to store extra area details...
+
-- convert to an hecho string and use hecho to display it
setAreaUserData(34, "country", "Andor.")
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
 
+
hecho(decho2hecho(dechoString))
-- or a sound file to play in the background (with a script that checks a room's area when entered)...
 
setAreaUserData(34, "backgroundSound", "/home/user/mudlet-data/soundFiles/birdsong.mp4")
 
 
 
-- can even store tables in it, using the built-in yajl.to_string function
 
setAreaUserData(101, "some table", yajl.to_string({ruler = "Queen Morgase Trakand", clan = "Lion Warden"}))
 
display("The ruler's name is: "..yajl.to_value(getRoomUserData(101, "some table")).ruler)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setCustomEnvColor==
+
==decho2html PR#6849 merged==
;setCustomEnvColor(environmentID, r,g,b,a)
+
; convertedString = decho2html(str[, resetFormat])
  
:Creates, or overrides an already created custom color definition for a given environment ID. Note that this will not work on the default environment colors - those are adjustable by the user in the preferences. You can however create your own environment and use a custom color definition for it.
+
:Converts a decho formatted string to an html formatted one.  
: See also: [[#getCustomEnvColorTable|getCustomEnvColorTable()]], [[#setRoomEnv|setRoomEnv()]]
+
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
  
{{note}} Numbers 1-16 and 257-272 are reserved by Mudlet. 257-272 are the default colors the user can adjust in mapper settings, so feel free to use them if you'd like - but don't overwrite them with this function.
+
{{MudletVersion|4.18}}
 
 
;Example
 
<syntaxhighlight lang="lua">
 
setRoomEnv(571, 200) -- change the room's environment ID to something arbitrary, like 200
 
local r,g,b = unpack(color_table.blue)
 
setCustomEnvColor(200, r,g,b, 255) -- set the color of environmentID 200 to blue
 
</syntaxhighlight>
 
 
 
==setDoor==
 
;setDoor(roomID, exitCommand, doorStatus)
 
 
 
:Creates or deletes a door in a room. Doors are purely visual - they don't affect pathfinding. You can use the information to adjust your speedwalking path based on the door information in a room, though.
 
 
 
:Doors CAN be set on stub exits ''- so that map makers can note if there is an obvious door to somewhere even if they do not (yet) know where it goes, perhaps because they do not yet have the key to open it!''
 
 
 
:Returns ''true'' if the change could be made, ''false'' if the input was valid but ineffective (door status was not changed), and ''nil'' with a message string on invalid input (value type errors).
 
 
 
: See also: [[#getDoors|getDoors()]]
 
  
 
;Parameters
 
;Parameters
* ''roomID:''
+
* ''str''
: Room ID to to create the door in.
+
: string you wish to convert from decho to decho
* ''exitCommand:''
+
* ''resetFormat''
: The cardinal direction for the door is in - it can be one of the following: '''n''', '''e''', '''s''', '''w''', '''ne''', '''se''', '''sw''', '''ne'''. ''{Plans are afoot to add support for doors on the other normal exits: '''up''', '''down''', '''in''' and '''out''', and also on special exits - though more work will be needed for them to be shown in the mapper.}''  It is important to ONLY use these direction codes as others e.g. "UP" will be accepted - because a special exit could have ANY name/lua script - but it will not be associated with the particular normal exit - recent map auditing code about to go into the code base will REMOVE door and other room exit items for which the appropriate exit (or stub) itself is not present, so in this case, in the absence of a special exit called "UP" that example door will not persist and not show on the normal "up" exit when that is possible later on.
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 
+
;Returns
* ''doorStatus:''
+
* a string formatted for html
: The door status as a number - '''0''' means no (or remove) door, '''1''' means open door (will draw a green square on exit), '''2''' means closed door (yellow square) and '''3''' means locked door (red square).
 
 
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- make a door on the east exit of room 4234 that is currently open
+
-- create the base string
setDoor(4234, 'e', 1)
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
 
 
-- remove a door from room 923 that points north
 
setDoor(923, 'n', 0)
 
</syntaxhighlight>
 
  
==setExit==
+
-- create a label to display the result onto
;setExit(from roomID, to roomID, direction)
+
testLabel = Geyser.Label:new({name = "testLabel"})
  
:Creates a one-way exit from one room to another using a standard direction - which can be either one of ''n, ne, nw, e, w, s, se, sw, u, d, in, out'', the long version of a direction, or a number which represents a direction. If there was an exit stub in that direction already, then it will be automatically deleted for you.
+
-- convert the decho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = decho2html(dechoString, testLabel:getFormat())
  
:Returns ''false'' if the exit creation didn't work.
+
-- and finally echo it to the label to see
 
+
-- I use rawEcho as that displays the html exactly as given.
: See also: [[#addSpecialExit|addSpecialExit()]]
+
testLabel:rawEcho(htmlString)
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- alias pattern: ^exit (\d+) (\d+) (\w+)$
 
-- so exit 1 2 5 will make an exit from room 1 to room 2 via north
 
 
 
if setExit(tonumber(matches[2]), tonumber(matches[3]), matches[4]) then
 
  echo("\nExit set to room:"..matches[3].." from "..matches[2]..", direction:"..string.upper(matches[3]))
 
else
 
  echo("Failed to set the exit.\n")
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
This function can also delete exits from a room if you use it like so:
+
==deleteMultiline PR #6779 merged==
  
<syntaxhighlight lang="lua">setExit(from roomID, -1, direction)</syntaxhighlight>
+
; ok,err = deleteMultiline([triggerDelta])
  
- which will delete an outgoing exit in the specified direction from a room.
+
:Deletes all lines between when the multiline trigger fires and when the first trigger matched. Put another way, it deletes everything since the pattern in slot 1 matched.
 +
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]
  
==setExitStub==
+
{{MudletVersion|4.18}}
;setExitStub(roomID, direction, set/unset)
 
  
Creates or removes an exit stub from a room in a given directions. You can use exit stubs later on to connect rooms that you're sure of are together. Exit stubs are also shown visually on the map, so the mapper can easily tell which rooms need finishing.
+
{{note}} This deletes all the lines since the first match of the multiline trigger matched. Do not use this if you do not want to delete ALL of those lines.
  
 
;Parameters
 
;Parameters
* ''roomID:''
+
* ''[optional]triggerDelta:''
: The room to place an exit stub in, as a number.
+
: The line delta from the multiline trigger it is being called from. It is best to pass this in to ensure all lines are caught. If not given it will try to guess based on the number of patterns how many lines at most it might have to delete.
* ''direction:''
 
: The direction the exit stub should lead in - as a short direction name ("nw"), long direction name ("northwest") or a number.
 
* ''set/unset:''
 
: A boolean to create or delete the exit stub.
 
  
: See also: [[#getExitStubs|getExitStubs()]], [[#connectExitStub|connectExitStub()]]
+
;Returns
 +
* true if the function was able to run successfully, nil+error if something went wrong.
  
 
;Example
 
;Example
Create an exit stub to the south from room 8:
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setExitStub(8, "s", true)
+
-- if this trigger has a line delta of 3, you would call
</syntaxhighlight>
+
deleteMultiline(3)
  
How to delete all exit stubs in a room:
+
-- same thing, but with error handling
<syntaxhighlight lang="lua">
+
local ok,err = deleteMultiline(3)
for i,v in pairs(getExitStubs(roomID)) do
+
if not ok then
   setExitStub(roomID, v,false)
+
   cecho("\n<firebrick>I could not delete the lines because: " .. err)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setExitWeight==
+
; Additional development notes
;setExitWeight(roomID, exitCommand, weight)
 
  
:Gives an exit a weight, which makes it less likely to be chosen for pathfinding. All exits have a weight of 0 by default, which you can increase. Exit weights are set one-way on an exit - if you'd like the weight to be applied both ways, set it from the reverse room and direction as well.
+
==echoPopup, revised in PR #6946==
 +
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])
 +
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if there is one extra hint then the first one will be used as a (maybe containing Qt rich-text markup) tool-tip for the text otherwise the remaining hints will be concatenated, one-per-line, as a tool-tip when the text is hovered over by the pointer.
  
;Parameters
+
; Parameters
* ''roomID:''
+
* ''windowName:''
: Room ID to to set the weight in.
+
: (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.
* ''exitCommand:''
+
* ''text:''
: The direction for the exit is in - it can be one of the following: '''n''', '''ne''', '''e''', '''se''', '''s''', '''sw''', '''w''', '''nw''', '''up''', '''down''', '''in''', '''out''', or, if it's a special exit, the special exit command - note that the strings for normal exits are case-sensitive and must currently be exactly as given here.
+
: the text string to display.
* ''weight:''
+
* ''{commands}:''
: Exit weight - by default, all exits have a weight of 0 meaning that the weight of the ''destination room'' is use when the route finding code is considering whether to use that exit; setting a value for an exit can increase or decrease the chance of that exit/destination room being used for a route by the route-finding code.  For example, if the destination room has very high weight compared to it's neighbors but the exit has a low value then that exit and thus the room is more likely to be used than if the exit was not weighted.
+
: 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}:''
: See also: [[#getExitWeights|getExitWeights()]]
+
: a table of strings which will be shown on the right-click menu and as a tool-tip for the ''text''. If the number is the same as that of the ''commands'' table then they all will be used for the right-click menu and listed (one per line) as a plain text tooltip; alternatively if there is one extra in number than the ''commands'' table the first will be used purely for the tool tip and the remainder will be used for the right-click menu. This additional entry may be formatted as Qt style "rich-text" (in the same manner as labels elsewhere in the GUI).
 
+
::* If a particular position in the ''commands'' table is an empty string ''""'' but there is something in the ''hints'' table then it will be listed in the right-click menu but as it does not do anything it will be shown ''greyed-out'' i.e. disabled and will not be clickable.
==setGridMode==
+
::* If a particular position in '''both''' the ''commands'' and the ''hints'' table are empty strings ''""'' then this item will show as a ''separator'' (usually as a horizontal-line) in the right-click menu and it will not be clickable/do anything.  
;setGridMode(areaID, true/false)
+
* ''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.
:Enables grid/wilderness view mode for an area - this will cause the rooms to lose their visible exit connections, like you'd see on compressed ASCII maps, both in 2D and 3D view mode; for the 2D map the custom exit lines will also not be shown if this mode is enabled.  
 
:Returns true if the area exists, otherwise false.
 
:[[File:Mapper-regular-mode.png|none|thumb|640x640px|regular mode]][[File:Mapper-grid-mode.png|none|thumb|631x631px|grid mode]]
 
 
 
: See also: [[#getGridMode|getGridMode()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setGridMode(55, true) -- set area with ID 55 to be in grid mode
+
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
</syntaxhighlight>
+
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
 
 
==setMapUserData==
 
;setMapUserData(key (as a string), value (as a string))
 
 
 
:Stores information about the map under a given key. Similar to Lua's key-value tables, except only strings may be used here. One advantage of using userdata is that it's stored within the map file itself - so sharing the map with someone else will pass on the user data. You can have as many keys as you'd like.
 
  
:Returns true if successfully set.
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
: See also: [[#clearMapUserData|clearMapUserData()]], [[#clearMapUserDataItem|clearMapUserDataItem()]], [[#getAllMapUserData|getAllMapUserData()]], [[#getMapUserData|getMapUserData()]]
+
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
  
;Example
+
-- one can also provide helpful information
<syntaxhighlight lang="lua">
 
-- store general meta information about the map...
 
setMapUserData("game_name", "Achaea Mudlet map")
 
  
-- or who the author was
+
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!
setMapUserData("author", "Bob")
+
echoPopup("Fancy popup", {[[echo("Doing command 1 (default one)")]], "", "", [[echo("Doing command 3")]], [[echo("Doing another command (number 4)"]], [[echo("Doing another command (number 5)"]])}, {"<p>This tooltip has HTML type tags in/around it, and it will get word-wrapped automatically to fit into a reasonable rectangle.</p><p><b>Plus</b> it can have those HTML like <i>effects</i> and be easily formatted into more than one paragraph and with <span style=\"color:cyan\">bits</span> in <span style=\"color:lime\">different</span> colors!</p><p>This example also demonstrates how to produce disabled menu (right-click) items, how to insert separators and how it now will handle multiple items with the same hint (prior to PR 6945 such duplicates will all run the command associated with the last one!) If the first command/function is an empty string then clicking on the text will have no effect, but hovering the mouse over the text will still produce the tooltip, this could be useful to display extra information about the text without doing anything by default.</p>", "Command 1 (default)", "", "Command 2 (disabled)", "Command 3", "Another command", "Another command"}, true)
 +
echo(" remaining text.\n")
  
-- can even store tables in it, using the built-in yajl.to_string function
 
setMapUserData("some table", yajl.to_string({game = "mud.com", port = 23}))
 
display("Available game info in the map: ")
 
display(yajl.to_value(getMapUserData("some table")))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMapZoom==
+
==hecho2cecho PR#6849 merged==
;setMapZoom(zoom[, areaID])
+
; convertedString = hecho2cecho(str)
  
:Zooms the 2D (only) map to a given zoom level. Larger numbers zooms the map further out. Revised in '''Mudlet ''4.17.0''''' to allow the zoom for an area to be specified even if it is not the one currently being viewed. This change is combined with Mudlet permanently remembering (it is saved within the map file) the zoom level last used for each area and with the addition of the ''getMapZoom()'' function.
+
:Converts a hecho formatted string to a cecho formatted one.  
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
:See also: [[Manual:Mapper_Functions#getMapZoom|getMapZoom()]].
+
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
* ''zoom:''
+
* ''str''
: floating point number that is at least 3.0 to set the zoom to.
+
: string you wish to convert from hecho to cecho
 
+
;Returns  
* ''areaID:''
+
* a string formatted for cecho
:(Optional and only since '''Mudlet ''4.17.0''''') Area ID number to adjust the 2D zoom for (''optional'', the function works on the area currently being viewed if this is omitted).
 
 
 
;Returns (only since '''Mudlet ''4.17.0''''')
 
* ''true'' on success
 
* ''nil'' and an error message on failure.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setMapZoom(10.0) -- zoom to a somewhat acceptable level, a bit big but easily visible connections
+
-- convert to a hecho string and use cecho to display it
true
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
 
+
cecho(hecho2cecho(hechoString))
setMapZoom(2.5 + getMapZoom(1), 1) -- zoom out the area with ID 1 by 2.5
 
true
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} The precise meaning of a particular zoom value may have an underlying meaning however that has not been determined other than that the minimum value is 3.0 and the initial value - and what prior Mudlet versions started each session with - is 20.0.
+
==hecho2decho PR#6849 merged==
 +
; convertedString = hecho2decho(str)
  
==setRoomArea==
+
:Converts a hecho formatted string to a decho formatted one.
;setRoomArea(roomID, newAreaID or newAreaName)
+
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
:Assigns the given room to a new or different area. If the area is displayed in the mapper this will have the room be visually moved into the area as well.
+
{{MudletVersion|4.18}}
  
: See also: [[#resetRoomArea|resetRoomArea()]]
+
;Parameters
 
+
* ''str''
==setRoomChar==
+
: string you wish to convert from hecho to decho
;setRoomChar(roomID, character)
+
;Returns
 
+
* a string formatted for decho
:Originally designed for an area in grid mode, takes a single ASCII character and draws it on the rectangular background of the room in the 2D map. In versions prior to Mudlet 3.8, the symbol can be cleared by using "_" as the character. In Mudlet version 3.8 and higher, the symbol may be cleared with either a space <code>" "</code> or an empty string <code>""</code>.
 
 
 
;Game-related symbols for your map
 
* [https://github.com/toddfast/game-icons-net-font toddfast's font] - 3000+ scalable vector RPG icons from [https://game-icons.net game-icons.net], as well as a script to download the latest icons and generate a new font.
 
* Pixel Kitchen's [https://www.fontspace.com/donjonikons-font-f30607 Donjonikon Font] - 10x10 fantasy and RPG-related icons.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setRoomChar(431, "#")
+
-- convert to a decho string and use decho to display it
 
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
setRoomChar(123, "$")
+
decho(hecho2decho(hechoString))
 
 
-- emoji's work fine too, and if you'd like it coloured, set the font to Nojo Emoji in settings
 
setRoomChar(666, "👿")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
:'''Since Mudlet version 3.8 :''' this facility has been extended:
+
==hecho2html PR#6849 merged==
:* This function will now take a short string of any printable characters as a room ''symbol'', and they will be shrunk to fit them all in horizontally but if they become too small that ''symbol'' may not be shown if the zoom is such that the room symbol is too small to be legible.
+
; convertedString = hecho2html(str[, resetFormat])
:* As "_" is now a valid character an existing symbol may be erased with either a space " " or an empty string "" although neither may be effective in some previous versions of Mudlet.
 
:* Should the rooms be set to be drawn as circles this is now accommodated and the symbol will be resized to fit the reduce drawing area this will cause.
 
:* The range of characters that are available are now dependent on the '''fonts''' present in the system and a setting on the "Mapper" tab in the preferences that control whether a specific font is to be used for all symbols (which is best if a font is included as part of a game server package, but has the issue that it may not be displayable if the user does not have that font or chooses a different one) or any font in the user's system may be used (which is the default, but may not display the ''glyph'' {the particular representation of a ''grapheme'' in a particular font} that the original map creator expected).  Should it not be possible to display the wanted symbol in the map because one or more of the required glyphs are not available in either the specified or any font depending on the setting then the ''replacement character'' (Unicode ''code-point'' U+FFFD '�') will be shown instead.  To allow such missing symbols to be handled the "Mapper" tab on the preferences dialogue has an option to display:
 
::* an indicator to show whether the symbol can be made just from the selected font (green tick), from the fonts available in the system (yellow warning triangle) or not at all (red cross)
 
::* all the symbols used on the map and how they will be displayed both only using the selected font and all fonts
 
::* the sequence of code-points used to create the symbol which will be useful when used in conjunction with character selection utilities such as ''charmap.exe'' on Windows and ''gucharmap'' on unix-like system
 
::* a count of the rooms using the particular symbol
 
::* a list, limited in entries of the first rooms using that symbol
 
:* The font that is chosen to be used as the primary (or only) one for the room symbols is stored in the Mudlet map data so that setting will be included if a binary map is shared to other Mudlet users or profiles on the same system.
 
  
: See also: [[#getRoomChar|getRoomChar()]]
+
:Converts a hecho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
==setRoomCharColor==
+
{{MudletVersion|4.18}}
;setRoomCharColor(roomId, r, g, b)
 
  
 
;Parameters
 
;Parameters
* ''roomID:''
+
* ''str''
: Room ID to to set char color to.
+
: string you wish to convert from hecho to hecho
* ''r:''
+
* ''resetFormat''
: Red component of room char color (0-255)
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
* ''g:''
+
;Returns
: Green component of room char color (0-255)
+
* a string formatted for html
* ''b:''
 
: Blue component of room char color (0-255)
 
 
 
Sets color for room symbol.
 
 
 
<syntaxhighlight lang="lua">
 
setRoomCharColor(2402, 255, 0, 0)
 
setRoomCharColor(2403, 0, 255, 0)
 
setRoomCharColor(2404, 0, 0, 255)
 
</syntaxhighlight>
 
 
 
{{MudletVersion|4.11}}
 
 
 
: See also: [[#unsetRoomCharColor|unsetRoomCharColor()]]
 
 
 
==setRoomCoordinates==
 
;setRoomCoordinates(roomID, x, y, z)
 
 
 
:Sets the given room ID to be at the following coordinates visually on the map, where ''z'' is the up/down level. These coordinates are define the location of the room within a particular area (so not globally on the overall map).
 
 
 
{{note}} 0,0,0 is the center of the map.
 
 
 
;Examples
 
<syntaxhighlight lang="lua">
 
-- alias pattern: ^set rc (-?\d+) (-?\d+) (-?\d+)$
 
-- this sets the current room to the supplied coordinates
 
setRoomCoordinates(roomID,x,y,z)
 
centerview(roomID)
 
</syntaxhighlight>
 
 
 
:You can make them relative asa well:
 
 
 
<syntaxhighlight lang="lua">
 
-- alias pattern: ^src (\w+)$
 
 
 
local x,y,z = getRoomCoordinates(previousRoomID)
 
local dir = matches[2]
 
 
 
if dir == "n" then
 
  y = y+1
 
elseif dir == "ne" then
 
  y = y+1
 
  x = x+1
 
elseif dir == "e" then
 
  x = x+1
 
elseif dir == "se" then
 
  y = y-1
 
  x = x+1
 
elseif dir == "s" then
 
  y = y-1
 
elseif dir == "sw" then
 
  y = y-1
 
  x = x-1
 
elseif dir == "w" then
 
  x = x-1
 
elseif dir == "nw" then
 
  y = y+1
 
  x = x-1
 
elseif dir == "u" or dir == "up" then
 
  z = z+1
 
elseif dir == "down" then
 
  z = z-1
 
end
 
setRoomCoordinates(roomID,x,y,z)
 
centerview(roomID)
 
</syntaxhighlight>
 
 
 
==setRoomEnv==
 
;setRoomEnv(roomID, newEnvID)
 
 
 
:Sets the given room to a new environment ID. You don't have to use any functions to create it - can just set it right away.
 
: See also: [[#setCustomEnvColor|setCustomEnvColor()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setRoomEnv(551, 34) -- set room with the ID of 551 to the environment ID 34
+
-- create the base string
</syntaxhighlight>
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
 
 
==setRoomIDbyHash==
 
;setRoomIDbyHash(roomID, hash)
 
 
 
:Sets the hash to be associated with the given roomID. See also [[#getRoomIDbyHash|getRoomIDbyHash()]].
 
 
 
:If the room was associated with a different hash, or vice versa, that association will be superseded.
 
  
==setRoomName==
+
-- create a label to display the result onto
;setRoomName(roomID, newName)
+
testLabel = Geyser.Label:new({name = "testLabel"})
  
:Renames an existing room to a new name.
+
-- convert the hecho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = hecho2html(hechoString, testLabel:getFormat())
  
;Example
+
-- and finally echo it to the label to see
<syntaxhighlight lang="lua">
+
-- I use rawEcho as that displays the html exactly as given.
setRoomName(534, "That evil room I shouldn't visit again.")
+
testLabel:rawEcho(htmlString)
lockRoom(534, true) -- and lock it just to be safe
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setRoomUserData==
+
==insertPopup, revised in PR #6925==
;setRoomUserData(roomID, key (as a string), value (as a string))
+
;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.
  
:Stores information about a room under a given key. Similar to Lua's key-value tables, except only strings may be used here. One advantage of using userdata is that it's stored within the map file itself - so sharing the map with someone else will pass on the user data. You can have as many keys as you'd like.  
+
; Parameters
 
+
* ''windowName:''
:Returns true if successfully set.
+
: (optional) name of the window as a string to echo to. Use either ''main'' or omit for the main window, or the miniconsole's or user-window's name otherwise.
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]]
+
* ''text:''
 
+
: the text string to display.
 
+
* ''{commands}:''
;Example
+
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
<syntaxhighlight lang="lua">
+
* ''{hints}:''
-- can use it to store room descriptions...
+
: 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.
setRoomUserData(341, "description", "This is a plain-looking room.")
+
* ''{tool-tips}:''
 
+
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided.  
-- or whenever it's outdoors or not...
+
* ''useCurrentFormatElseDefault:''
setRoomUserData(341, "outdoors", "true")
+
: (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.
 
 
-- how how many times we visited that room
 
local visited = getRoomUserData(341, "visitcount")
 
visited = (tonumber(visited) or 0) + 1
 
setRoomUserData(341, "visitcount", tostring(visited))
 
 
 
-- can even store tables in it, using the built-in yajl.to_string function
 
setRoomUserData(341, "some table", yajl.to_string({name = "bub", age = 23}))
 
display("The denizens name is: "..yajl.to_value(getRoomUserData(341, "some table")).name)
 
</syntaxhighlight>
 
 
 
==setRoomWeight==
 
;setRoomWeight(roomID, weight)
 
 
 
:Sets a weight to the given roomID. By default, all rooms have a weight of 1 - the higher the weight is, the more likely the room is to be avoided for pathfinding. For example, if travelling across water rooms takes more time than land ones - then you'd want to assign a weight to all water rooms, so they'd be avoided if there are possible land pathways.
 
 
 
{{note}} The minimum allowed room weight is 1.
 
 
 
:To completely avoid a room, make use of [[#lockRoom|lockRoom()]].
 
 
 
: See also: [[#getRoomWeight|getRoomWeight()]]
 
 
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
setRoomWeight(1532, 3) -- avoid using this room if possible, but don't completely ignore it
 
</syntaxhighlight>
 
 
 
 
 
==speedwalk==
 
;speedwalk(dirString, backwards, delay, show)
 
  
:A speedwalking function will work on cardinal+ordinal directions (n, ne, e, etc.) as well as u (for up), d (for down), in and out. It can be called to execute all directions directly after each other, without delay, or with a custom delay, depending on how fast your game allows you to walk. It can also be called with a switch to make the function reverse the whole path and lead you backwards.
+
{{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.
 
 
:Call the function by doing: <code>speedwalk("YourDirectionsString", true/false, delaytime, true/false)</code>
 
 
 
:The delaytime parameter will set a delay between each move (set it to 0.5 if you want the script to move every half second, for instance). It is optional: If you don't indicate it, the script will send all direction commands right after each other. (If you want to indicate a delay, you -have- to explicitly indicate true or false for the reverse flag.)
 
 
 
:The show parameter will determine if the commands sent by this function are shown or hidden. It is optional: If you don't give a value, the script will show all commands sent. (If you want to use this option, you -have- to explicitly indicate true or false for the reverse flag, as well as either some number for the delay or nil if you do not want a delay.)
 
 
 
:The "YourDirectionsString" contains your list of directions and steps (e.g.: "2n, 3w, u, 5ne"). Numbers indicate the number of steps you want it to walk in the direction specified after it. The directions must be separated by anything other than a letter that can appear in a direction itself. (I.e. you can separate with a comma, spaces, the letter x, etc. and any such combinations, but you cannot separate by the letter "e", or write two directions right next to each other with nothing in-between, such as "wn". If you write a number before every direction, you don't need any further separator. E.g. it's perfectly acceptable to write "3w1ne2e".) The function is not case-sensitive.
 
 
 
:If your game only has cardinal directions (n,e,s,w and possibly u,d) and you wish to be able to write directions right next to each other like "enu2s3wdu", you'll have to change the pattern slightly. Likewise, if your game has any other directions than n, ne, e, se, s, sw, w, nw, u, d, in, out, the function must be adapted to that.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
speedwalk("16d1se1u")
+
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
-- Will walk 16 times down, once southeast, once up. All in immediate succession.
+
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
  
speedwalk("2ne,3e,2n,e")
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
-- Will walk twice northeast, thrice east, twice north, once east. All in immediate succession.
+
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
  
speedwalk("IN N 3W 2U W", false, 0.5)
+
-- one can also provide helpful information
-- Will walk in, north, thrice west, twice up, west, with half a second delay between every move.
 
  
speedwalk("5sw - 3s - 2n - w", true)
+
-- todo: an example with rich-text in the tool-tips(s)
-- Will walk backwards: east, twice south, thrice north, five times northeast. All in immediate succession.
 
  
speedwalk("3w, 2ne, w, u", true, 1.25)
 
-- Will walk backwards: down, east, twice southwest, thrice east, with 1.25 seconds delay between every move.
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} The probably most logical usage of this would be to put it in an alias. For example, have the pattern ''^/(.+)$'' execute: <code>speedwalk(matches[2], false, 0.7)</code>
+
=Discord Functions=
And have ''^//(.+)$'' execute: <code>speedwalk(matches[2], true, 0.7)</code>
+
: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]].
Or make aliases like: ''^banktohome$'' to execute <syntaxhighlight lang="lua" inline>speedwalk("2ne,e,ne,e,3u,in", true, 0.5)</syntaxhighlight>
 
  
{{note}} The show parameter for this function is available in Mudlet 3.12+
+
=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]].
  
==stopSpeedwalk==
+
=Supported Protocols=
;stopSpeedwalk()
 
  
:Stops a speedwalk started using [[#speedwalk|speedwalk()]]
+
=Events=
: See also: [[#pauseSpeedwalk|pauseSpeedwalk()]], [[#resumeSpeedwalk|resumeSpeedwalk()]], [[#speedwalk|speedwalk()]]
+
: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.
  
{{MudletVersion|4.13}}
+
===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.
  
<syntaxhighlight lang="lua">
+
{{MudletVersion| ?.??}}
local ok, err = stopSpeedwalk()
 
if not ok then
 
  cecho(f"\n<red>Error:<reset> {err}")
 
  return
 
end
 
cecho(f"\n<green>Success:<reset> speedwalk stopped")
 
</syntaxhighlight>
 
  
==unHighlightRoom==
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615
;unHighlightRoom(roomID)
 
  
:Unhighlights a room if it was previously highlighted and restores the rooms original environment color.
+
===sysMapWindowMousePressEvent, PR #6962===
: See also: [[#highlightRoom|highlightRoom()]]
+
Raised when the mouse is left-clicked on the mapper window.
  
;Example
+
{{MudletVersion| ?.??}}
<syntaxhighlight lang="lua">
 
unHighlightRoom(4534)
 
</syntaxhighlight>
 
  
==unsetRoomCharColor==
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962
;unsetRoomCharColor(roomId)
 
  
;Parameters
+
===sysWindowOverflowEvent, PR #6872===
* ''roomID:''
+
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.
: Room ID to to unset char color to.
 
  
Removes char color setting from room, back to automatic determination based on room background lightness.
+
{{MudletVersion| ?.??}}
 
 
<syntaxhighlight lang="lua">
 
unsetRoomCharColor(2031)
 
</syntaxhighlight>
 
  
{{MudletVersion|4.11}}
+
{{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).
 
 
==updateMap==
 
;updateMap()
 
 
 
:Updates the mapper display (redraws it). Use this function if you've edited the map via script and would like the changes to show.
 
 
 
: See also: [[#centerview|centerview()]]
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- delete a some room
 
deleteRoom(500)
 
-- now make the map show that it's gone
 
updateMap()
 
</syntaxhighlight>
 

Revision as of 20:57, 7 July 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.

updateMap

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


mapSymbolFontInfo, PR #4038 closed

mapSymbolFontInfo()
See also: setupMapSymbolFont()

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

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

moveMapLabel, PR #6014 open

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

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

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

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

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

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

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

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

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

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

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

moveRoom, PR #6010 open

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

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

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

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

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

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

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

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

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

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

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

setupMapSymbolFont, PR #4038 closed

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

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

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

Miscellaneous Functions

Miscellaneous functions.

compare, PR#7122 open

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

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

createVideoPlayer, PR #6439

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

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

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

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

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

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

loadVideoFile, PR #6439

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

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

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

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

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

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

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

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

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

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

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

playVideoFile, PR #6439

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


stopVideos, PR #6439

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

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

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

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

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

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

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

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

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


getCustomLoginTextId, PR #3952 open

getCustomLoginTextId()

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

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

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

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

Only one custom login text has been defined initially:

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

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

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

sendCharacterName, PR #3952 open

sendCharacterName()

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

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

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

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

sendCharacterPassword, PR #3952 open

sendCharacterPassword()

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

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

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

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

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

sendCustomLoginText, PR #3952 open

sendCustomLoginText()

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

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

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

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

Only one custom login text has been defined initially:

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

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

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

Mudlet Object Functions

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

ancestors, new in PR #6726

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

findItems, new in PR #6742

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

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

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

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

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

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

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

isActive, modified by PR #6726

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

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

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

isAncestorsActive, new in PR #6726

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

Networking Functions

A collection of functions for managing networking.

sendSocket revised in PR #7066 (Open)

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

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

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

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

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

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

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

-- This function is still being written up.

feedTelnet added in PR #7066 (Open)==

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

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

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

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

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

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

-- This function is still being written up.

String Functions

These functions are used to manipulate strings.

Table Functions

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

Text to Speech Functions

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

UI Functions

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

cecho2decho PR#6849 merged

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

cecho2hecho PR#6849 merged

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

cecho2html PR#6849 merged

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

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

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

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

decho2cecho PR#6849 merged

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

decho2hecho PR#6849 merged

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

decho2html PR#6849 merged

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

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

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

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

deleteMultiline PR #6779 merged

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

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

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

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

echoPopup, revised in PR #6946

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

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

-- one can also provide helpful information

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

hecho2cecho PR#6849 merged

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

hecho2decho PR#6849 merged

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

hecho2html PR#6849 merged

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

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

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

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

insertPopup, revised in PR #6925

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

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

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

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

-- one can also provide helpful information

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

Discord Functions

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

Mud Client Media Protocol

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

Supported Protocols

Events

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

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