Difference between revisions of "Manual:Mapper Functions"

From Mudlet
Jump to navigation Jump to search
 
(222 intermediate revisions by 18 users not shown)
Line 1: Line 1:
 
{{TOC right}}
 
{{TOC right}}
 +
{{#description2:Mudlet API documentation for functions that manipulate the mapper and its related features.}}
 
= Mapper Functions =
 
= Mapper Functions =
These are functions that are to be used with the Mudlet Mapper. The mapper is designed to be MUD-generic - it only provides the display and pathway calculations, to be used in Lua scripts that are tailored to the MUD 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.
+
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:
 
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:
Line 16: Line 17:
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local newId, err = addAreaName(string.random(10))
+
local newId, err = addAreaName("My House")
  
 
if newId == nil or newId < 1 or err then
 
if newId == nil or newId < 1 or err then
Line 39: Line 40:
 
* ''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).
 
* ''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.
 
* ''style:'' a string, one of: "solid line", "dot line", "dash line", "dash dot line" or "dash dot dot line" exactly.
 +
: how these look can be seen in the [[Manual:Mapper#Map_Legend|Map Legend section]] of the manual
 
* ''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.
 
* ''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.
 
* ''arrow:'' a boolean which if true will set the custom line to have an arrow on the end of the last segment.
  
{{note}} Available since Mudlet 3.0.
+
{{MudletVersion|3.0}}
  
 
;Examples
 
;Examples
Line 49: Line 51:
 
addCustomLine(1, 2, "N", "dot line", {0, 255, 255}, true)
 
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)
+
addCustomLine(1, {{1, 2, 0}, {1, 4, 0}, {0, 5, 0}}, "N", "dash dot dot line", {128, 128, 0}, false)
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
The second custom exit will look like the below screenshot.
  
 
A bigger example that'll create a new area and the room in it:
 
A bigger example that'll create a new area and the room in it:
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local areaid = addAreaName("my first area")
+
local areaid = addAreaName("Custom Exit Playground")
local newroomid = createRoomID()
+
local firstRoom = createRoomID()
addRoom(newroomid)
+
addRoom(firstRoom, areaid)
setRoomArea(newroomid, "my first area")
+
setRoomCoordinates(firstRoom, 0, 0, 0)
setRoomCoordinates(newroomid, 0, 0, 0)
+
 
 +
local secondRoom = createRoomID()
 +
addRoom(secondRoom, areaid)
 +
setRoomCoordinates(secondRoom, 0, 5, 0)
  
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)
+
-- make a special exit for this room, and a custom exit line
 +
addSpecialExit(firstRoom, secondRoom, "climb Rope")
 +
addCustomLine(firstRoom, {{1, 2, 0}, {1, 4, 0}, {0, 5, 0}}, "climb Rope", "dash dot dot line", {128, 128, 0}, false)
  
centerview(newroomid)
+
centerview(firstRoom)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Note: At the time of writing there is no Lua command to remove a custom exit line and, for Normal exits in the X-Y plane, revert to the standard straight line between the start room and the end room (or colored arrow for out of area exits) however this can be done from the GUI interface to the 2D mapper.
+
This should result in a map with a custom exit looking something like the following.
 +
 
 +
[[File:Custom exits.png|500px|center]]
  
 
==addMapEvent==
 
==addMapEvent==
Line 80: Line 91:
 
addMapEvent("room b", "onFavorite", "Favorites", "Special Room!", 12345, "arg1", "arg2", "argn")  
 
addMapEvent("room b", "onFavorite", "Favorites", "Special Room!", 12345, "arg1", "arg2", "argn")  
 
</syntaxhighlight>
 
</syntaxhighlight>
The last line will make a label "Special Room!" under the "Favorites" menu that on clicking will send all the arguments.
+
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)
 +
  local selectedRooms = getMapSelection()["rooms"]
 +
  for i, val in ipairs(selectedRooms) do
 +
    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")
 +
</syntaxhighlight>
 +
This create menu and two submenu options: "Mark selected rooms as Death Trap" and "Mark selected rooms as single-pass"
  
 
==addMapMenu==
 
==addMapMenu==
Line 90: Line 133:
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
addMapMenu("Favorites") -- will create a menu, favorites
+
-- This will create a menu named: Favorites.
 +
addMapMenu("Favorites")
  
addMapMenu("Favorites1234343", "Favorites", "Favorites")  
+
-- This will create a submenu with the unique id 'Favorites123' under 'Favorites' with the display name of 'More Favorites'.
 +
addMapMenu("Favorites1234343", "Favorites", "More Favorites")  
 
</syntaxhighlight>
 
</syntaxhighlight>
The last line will create a submenu with the unique id ''Favorites123''.. under Favorites with the display name of ''Favorites''.
 
  
 
==addRoom==
 
==addRoom==
Line 102: Line 146:
  
 
{{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}} 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()]]
 
: See also: [[#createRoomID|createRoomID()]]
  
;Example
+
;Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
local newroomid = createRoomID()
 
local newroomid = createRoomID()
Line 111: Line 157:
  
 
==addSpecialExit==
 
==addSpecialExit==
;addSpecialExit(roomIDFrom, roomIDTo, command)
+
;addSpecialExit(roomIDFrom, roomIDTo, moveCommand)
  
 
:Creates a one-way from one room to another, that will use the given command for going through them.
 
: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()]]
+
 
 +
: See also: [[#clearSpecialExits|clearSpecialExits()]], [[#removeSpecialExit|removeSpecialExit()]], [[#setExit|setExit()]]
  
 
;Example
 
;Example
Line 130: Line 177:
 
centerview(currentroom)
 
centerview(currentroom)
 
</syntaxhighlight>
 
</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==
Line 158: Line 212:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Available since Mudlet 3.0.
+
{{MudletVersion|3.0}}
  
 
==clearAreaUserDataItem==
 
==clearAreaUserDataItem==
Line 166: Line 220:
 
: See also: [[#setAreaUserData|setAreaUserData()]], [[#clearAreaUserData|clearAreaUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]
 
: See also: [[#setAreaUserData|setAreaUserData()]], [[#clearAreaUserData|clearAreaUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]
  
{{note}} Available since Mudlet 3.0.
+
{{MudletVersion|3.0}}
  
 
;Example
 
;Example
Line 187: Line 241:
 
false
 
false
 
</syntaxhighlight>
 
</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==
Line 195: Line 258:
 
: See also: [[#setMapUserData|setMapUserData()]], [[#clearRoomUserData|clearRoomUserData()]], [[#clearAreaUserData|clearAreaUserData()]]
 
: See also: [[#setMapUserData|setMapUserData()]], [[#clearRoomUserData|clearRoomUserData()]], [[#clearAreaUserData|clearAreaUserData()]]
  
{{note}} Available since Mudlet 3.0.
+
{{MudletVersion|3.0}}
  
 
;Example
 
;Example
Line 209: Line 272:
  
 
==clearMapUserDataItem==
 
==clearMapUserDataItem==
;clearUserDataItem(mapID, key)
+
;clearMapUserDataItem(mapID, key)
  
 
:Removes the specific key and value from the user data from the map user data.
 
:Removes the specific key and value from the user data from the map user data.
Line 234: Line 297:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Available since Mudlet 3.0.
+
{{MudletVersion|3.0}}
  
 
==clearRoomUserData==
 
==clearRoomUserData==
Line 240: Line 303:
  
 
:Clears all user data from a given room.
 
:Clears all user data from a given room.
: See also: [[#setRoomUserData|setRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]:
+
: 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.
 
{{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.
Line 296: Line 359:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Available since Mudlet 3.0.
+
{{MudletVersion|3.0}}
 
 
''As a work around for the absence of this and some other room user data commands in prior versions {which only possesses the clearRoomUserData() command but does not have anything to find out and preserve what data key-value pairs might have been used from other packages}, a suggested work around is to use a setRoomUserData(key,"") to empty any unwanted data and to treat data items with empty values the same as non-existent data items - when the user updates to a version '''with''' these commands a script could then detect and purge data items with keys that it is concerned with but which have only an empty string as a value...''
 
  
 
==clearSpecialExits==
 
==clearSpecialExits==
Line 314: Line 375:
 
end
 
end
 
</syntaxhighlight>
 
</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==
;connectExitStub(fromID, direction or toID[, optional direction])
+
;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.
 
: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.
Line 323: Line 391:
 
* ''fromID:''
 
* ''fromID:''
 
: Room ID to set the exit stub in.
 
: Room ID to set the exit stub in.
* ''direction or toID:''
+
* ''direction:''
: You can either specify the direction to link the room in, or a specific room ID. Direction can be specified as a number, short direction name ("nw") or long direction name ("northwest").
+
: 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:''
 
* ''toID:''
: Optional - 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.
+
: 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()]]
 
: See also: [[#setExitStub|setExitStub()]], [[#getExitStubs|getExitStubs()]]
Line 334: Line 402:
 
-- try and connect all stubs that are in a room
 
-- try and connect all stubs that are in a room
 
local stubs = getExitStubs(roomID)
 
local stubs = getExitStubs(roomID)
  if stubs then
+
if stubs then
    for i,v in pairs(stubs) do
+
  for i,v in pairs(stubs) do
 
     connectExitStub(roomID, v)
 
     connectExitStub(roomID, v)
 
   end
 
   end
Line 342: Line 410:
  
 
==createMapLabel==
 
==createMapLabel==
;labelID = createMapLabel(areaID, text, posx, posy, posz, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue, zoom, fontSize, showOnTop, noScaling)
+
;labelID = createMapLabel(areaID, text, posX, posY, posZ, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue[, zoom, fontSize, showOnTop, noScaling, fontName, foregroundTransparency, backgroundTransparency, temporary])
  
: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. It returns a label ID that you can use later for deleting it.
+
:Creates a text label on the map at given coordinates, with the given background and foreground colors. It can go above or below the rooms, scale with zoom or stay a static size. From Mudlet 4.17.0 an additional parameter (assumed to be false if not given from then) makes the label NOT be saved in the map file which, if the image can be regenerated on future loading from a script can reduce the size of the saved map somewhat. It returns a label ID that you can use later for deleting it.
  
 
:The coordinates 0,0 are in the middle of the map, and are in sync with the room coordinates - so using the x,y values of [[#getRoomCoordinates|getRoomCoordinates()]] will place the label near that room.
 
:The coordinates 0,0 are in the middle of the map, and are in sync with the room coordinates - so using the x,y values of [[#getRoomCoordinates|getRoomCoordinates()]] will place the label near that room.
  
: See also: [[#getMapLabel|getMapLabel()]], [[#getMapLabels|getMapLabels()]]
+
: See also: [[#getMapLabel|getMapLabel()]], [[#getMapLabels|getMapLabels()]], [[#deleteMapLabel|deleteMapLabel]], [[#createMapImageLabel|createMapImageLabel()]]
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Historical Version Note</div>
 +
<div class="mw-collapsible-content">
 +
{{note}} Some changes were done prior to 4.13 (which exactly? function existed before!) - see corresponding PR and update here!
 +
</div></div></div>
  
 
;Parameters
 
;Parameters
Line 355: Line 429:
 
* ''text:''
 
* ''text:''
 
: The text to put into the label. To get a multiline text label add a '\n' between the lines.
 
: The text to put into the label. To get a multiline text label add a '\n' between the lines.
* ''posx, posy, posz:''
+
* ''posX, posY, posZ:''
: Position of the label in room coordinates.
+
: Position of the label in (floating point numbers) room coordinates.
* ''fgRed, fgGreen fgBlue:''
+
* ''fgRed, fgGreen, fgBlue:''
 
: Foreground color or text color of the label.
 
: Foreground color or text color of the label.
* ''bgRed, bgGreen bgBlue:''
+
* ''bgRed, bgGreen, bgBlue:''
 
: Background color of the label.
 
: Background color of the label.
 
* ''zoom:''
 
* ''zoom:''
: 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.
+
: (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:''
 
* ''fontSize:''
: Size of the font of the text. Default is 50.
+
: (optional, but needed if zoom is provided) Size of the font of the text. Default is 50.
 
* ''showOnTop:''
 
* ''showOnTop:''
: 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.
+
: (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:''
 
* ''noScaling:''
: 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.  
+
: (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:''
: See also: [[#deleteMapLabel|deleteMapLabel]]
+
: (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
Line 383: Line 463:
 
-- the position is placed somewhat to the northeast of the center of the map
 
-- the position is placed somewhat to the northeast of the center of the map
 
-- this label will be scaled as you zoom the map.
 
-- this label will be scaled as you zoom the map.
local labelid = createMapLabel( 50, "1. Row One\n2. Row 2", .5,5.5,0, 255,0,0, 23,0,0, 30,50, true,false)
+
local labelid = createMapLabel( 50, "1. Row One\n2. Row 2", .5,5.5,0, 255,0,0, 23,0,0, 30,50, true, false)
  
 +
local x,y,z = getRoomCoordinates(getPlayerRoom())
 +
createMapLabel(getRoomArea(getPlayerRoom()), "my map label", x,y,z, 255,0,0, 23,0,0, 0,20, false, true, "Ubuntu", 255, 100)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
==createMapImageLabel==
 
==createMapImageLabel==
;labelID = createMapImageLabel(areaID, filePath, posx, posy, posz, width, height, zoom, showOnTop)
+
;labelID = createMapImageLabel(areaID, filePath, posx, posy, posz, width, height, zoom, showOnTop[, temporary])
  
: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.
+
: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.
  
 
: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.
 
:The coordinates 0,0 are in the middle of the map, and are in sync with the room coordinates - so using the x,y values of [[#getRoomCoordinates|getRoomCoordinates()]] will place the label near that room.
: See also: [[#deleteMapLabel|deleteMapLabel]]
+
: See also: [[#createMapLabel|createMapLabel]], [[#deleteMapLabel|deleteMapLabel]]
  
 
;Example:
 
;Example:
Line 401: Line 483:
 
-- 0,0,0 are the x,y,z coordinates - so this will place it in the middle of the map
 
-- 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
 
-- 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 width of the image
+
-- 555 is the original height of the image
 
-- 100 is how much we zoom it by, 1 would be no zoom
 
-- 100 is how much we zoom it by, 1 would be no zoom
-- and lastly, false to make it go below our rooms
+
-- false to make it go below our rooms
createMapImageLabel(138, [[/home/vadi/Pictures/You only see what shown.png]], 0,0,0, 482/100, 555/100, 100, false)
+
-- (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==
 
==createMapper==
;createMapper(x, y, width, height)
+
;createMapper([name of userwindow], x, y, width, height)
  
 
: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.
 
: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.
 +
 +
{{note}} ''name of userwindow'' available in Mudlet 4.6.1+
 +
 +
{{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.
  
 
;Example
 
;Example
Line 428: Line 515:
 
}, main)
 
}, main)
 
</syntaxhighlight>
 
</syntaxhighlight>
 
{{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.
 
  
 
==createRoomID==
 
==createRoomID==
Line 437: Line 522:
  
 
;Parameters
 
;Parameters
* ''minimumStartingRoomId'' (optional):
+
* ''minimumStartingRoomId'' (optional, available in Mudlet 3.0+):
 
: 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.
 
: 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.
 
{{note}} ''minimumStartingRoomId'' is available since Mudlet 3.0.
 
  
 
: See also: [[#addRoom|addRoom()]]
 
: See also: [[#addRoom|addRoom()]]
Line 452: Line 535:
 
;Parameters
 
;Parameters
 
* ''areaID:''
 
* ''areaID:''
: Area ID to delete.
+
: Area ID to delete, or:
* ''areaName:''
+
* ''areaName'' (available in Mudlet 3.0+):
: Area name to delete (available since Mudlet 3.0).
+
: Area name to delete.
  
  
Line 463: Line 546:
 
-- or since Mudlet 3.0, by area name
 
-- or since Mudlet 3.0, by area name
 
deleteArea("Big city")
 
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
 +
:''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."''
 +
 +
{{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
 +
<syntaxhighlight lang="lua">
 +
deleteMap()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 468: Line 569:
 
;deleteMapLabel(areaID, labelID)
 
;deleteMapLabel(areaID, labelID)
  
:Deletes a map label from  a specfic area.
+
:Deletes a map label from  a specific area.
 
: See also: [[#createMapLabel|createMapLabel()]]
 
: See also: [[#createMapLabel|createMapLabel()]]
  
Line 486: Line 587:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==exportAreaImage==
+
==disableMapInfo==
;exportAreaImage(areaID)
+
;disableMapInfo(label)
 +
 
 +
Disable the particular map info - same as toggling off checkbox from select box under mapper.
 +
 
 +
;Parameters
 +
* ''label:''
 +
: Name under which map info to be disabled was registered.
  
:Exports the area as an image into your profile's directory.
+
: See also: [[#registerMapInfo|registerMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#killMapInfo|killMapInfo()]]
  
;Example
+
{{MudletVersion|4.11}}
<syntaxhighlight lang="lua">
 
-- save the area with ID 1 as a map
 
exportAreaImage(1)
 
</syntaxhighlight>
 
  
{{note}} This command is currently inoperable in current 3.0+ versions of Mudlet.
+
==enableMapInfo==
 +
;enableMapInfo(label)
  
==getAllMapUserData==
+
Enable the particular map info - same as toggling on checkbox from select box under mapper.
;dataTable = getAllMapUserData()
 
  
:Returns all the user data items stored at the map level; will return an empty table if there is no data stored.
+
;Parameters
 +
* ''label:''
 +
: Name under which map info to be enabled was registered.
  
: See also: [[#getMapUserData|getMapUserData()]]
+
: See also: [[#registerMapInfo|registerMapInfo()]], [[#disableMapInfo|disableMapInfo()]], [[#killMapInfo|killMapInfo()]]
  
;Example
+
{{MudletVersion|4.11}}
<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>
 
  
{{note}} Available in Mudlet 3.0 - requires Mudlet Map format 17 or later to save which has not yet been made the default as it is not compatible with Mudlet 2.1 and will be rejected by that version.  The format can be manually set to be the upgraded one in recent Mudlet development and release 3.0 previews via an option on the "Special Options" tab of the "Profile Preferences" (Options) dialogue. Attempting to use MapUserData or AreaUserData with the current default (backwards compatible) format (16) will produce a warning the first time in a session that a value is set and each time the Map file is saved.  Once this change has been made it will persist but leave an advisory message on loading in current Mudlet versions.
+
==getAllAreaUserData==
 +
;dataTable = getAllAreaUserData(areaID)
  
==getAllRoomUserData==
+
: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.
;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.
+
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#searchAreaUserData|searchAreaUserData()]], [[#setAreaUserData|setAreaUserData()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getAllRoomUserData(3441))
+
display(getAllAreaUserData(34))
 
--might result in:--
 
--might result in:--
 
{
 
{
   description = [[
+
   country = "Andor",
From this ledge you can see out across a large cavern to the southwest. The
+
   ruler = "Queen Morgase Trakand"
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>
 
</syntaxhighlight>
  
{{note}} Available in Mudlet 3.0.
+
{{MudletVersion|3.0}}
  
==getAreaExits==
+
==getAllMapUserData==
;roomTable = getAreaExits(areaID, showExits)
+
;dataTable = getAllMapUserData()
  
: 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.
+
:Returns all the user data items stored at the map level; will return an empty table if there is no data stored.
  
;Parameters
+
: See also: [[#getMapUserData|getMapUserData()]]
* ''areaID:''
 
: Area ID to list the exits for.
 
* ''showExits:''
 
: Boolean argument, if true then the exits that lead out to another area will be listed for each room.
 
 
 
: See also: [[#setExit|setExit()]], [[#getRoomExits|getRoomExits()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- list all border rooms for area 44:
+
display(getAllMapUserData())
getAreaExits(44)
+
--might result in:--
 
 
-- returns:
 
--[[
 
 
{
 
{
   7091,
+
   description = [[This map is about so and so game]],
   10659,
+
   author = "Bob",
   11112,
+
   ["last updated"] = "December 5, 2020"
  11122,
 
  11133,
 
  11400,
 
  12483,
 
  24012
 
 
}
 
}
]]
+
</syntaxhighlight>
 +
 
 +
{{MudletVersion|3.0}}
  
-- list all border rooms for area 44, and the exits within them that go out to other areas:
+
==getAllRoomEntrances==
getAreaExits(44, true)
+
;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:--
 
{
 
{
   [12483] = {
+
   description = [[
    north = 27278
+
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
  [11122] = {
+
weird rock formations. The west side has a path through it and an exit to the
    ["enter grate"] = 14551
+
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
  [11112] = {
+
reach to the south. It appears to have grown till it connects with the
    ["enter grate"] = 14829
+
stalagmite below it. Something smells... Yuck you are standing in bat guano!]],
  },
+
   doorname_up = "trapdoor"
  [24012] = {
 
    north = 22413
 
  },
 
  [11400] = {
 
    south = 10577
 
  },
 
  [11133] = {
 
    ["enter grate"] = 15610
 
  },
 
  [7091] = {
 
    down = 4411
 
  },
 
   [10659] = {
 
    ["enter grate"] = 15510
 
  }
 
 
}
 
}
]]
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getAreaRooms==
+
==getAreaExits==
;areaTable = getAreaRooms(area id)
+
;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
 +
* ''areaID:''
 +
: Area ID to list the exits for.
 +
* ''showExits:''
 +
: Boolean argument, if true then the exits that lead out to another area will be listed for each room.
  
:Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or ''nil'' if no such area exists.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- using the sample findAreaID() function defined in the getAreaTable() example,
+
-- list all border rooms for area 44:
-- we'll define a function that echo's us a nice list of all rooms in an area with their ID
+
getAreaExits(44)
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 ipairs(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
+
-- returns:
      cecho(string.format(
+
--[[
        "%6s: %s\n", roomid, roomname))
+
{
    end
+
  7091,
   elseif not id and msg then
+
  10659,
    echo("ID not found; " .. msg)
+
  11112,
   else
+
   11122,
    echo("No areas matched the query.")
+
  11133,
   end
+
   11400,
end
+
  12483,
</syntaxhighlight>
+
   24012
 +
}
 +
]]
  
==getAreaTable==
+
-- list all border rooms for area 44, and the exits within them that go out to other areas:
;areaTable = getAreaTable()
+
getAreaExits(44, true)
 
+
--[[
:Returns a key(area name)-value(area id) table with all known areas and their IDs. Some older versions of Mudlet return an area with an empty name and an ID of 0 included in it, you should ignore that.
+
{
 +
  [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>
  
: See also: [[#getAreaTableSwap|getAreaTableSwap()]]
+
==getAreaRooms==
 +
;getAreaRooms(area id)
 +
 
 +
:Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or ''nil'' if no such area exists. Indexing starts at 0.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- example function that returns the area ID for a given area
+
-- 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 findAreaID(areaname)
+
function echoRoomList(areaname)
   local list = getAreaTable()
+
   local id, msg = findAreaID(areaname)
 
+
   if id then
   -- iterate over the list of areas, matching them with substring match.
+
    local roomlist, endresult = getAreaRooms(id), {}
  -- if we get match a single area, then return it's ID, otherwise return
+
    
   -- 'false' and a message that there are than one are matches
+
    -- obtain a room list for each of the room IDs we got
  local returnid, fullareaname
+
    for _, id in pairs(roomlist) do
  for area, id in pairs(list) do
+
       endresult[id] = getRoomName(id)
    if area:find(areaname, 1, true) then
 
       if returnid then return false, "more than one area matches" end
 
      returnid = id; fullareaname = area
 
 
     end
 
     end
  end
 
 
    
 
    
  return returnid, fullareaname
+
    -- now display something half-decent looking
end
+
    cecho(string.format(
 +
      "List of all rooms in %s (%d):\n", msg, table.size(endresult)))
  
-- sample use:
+
    for roomid, roomname in pairs(endresult) do
local id, msg = findAreaID("blahblah")
+
      cecho(string.format(
if id then
+
        "%6s: %s\n", roomid, roomname))
  echo("Found a matching ID: " .. id")
+
    end
elseif not id and msg then
+
  elseif not id and msg then
  echo("ID not found; " .. msg)
+
    echo("ID not found; " .. msg)
else
+
  else
  echo("No areas matched the query.")
+
    echo("No areas matched the query.")
 +
  end
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getAreaTableSwap==
+
==getAreaTable==
;areaTable = getAreaTableSwap()
+
;areaTable = getAreaTable()
 
 
: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. 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==
+
:Returns a key(area name)-value(area id) table with all known areas and their IDs.
;dataTable = 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.  
+
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Historical Version Note</div>
 +
<div class="mw-collapsible-content">
 +
{{Note}} Some older versions of Mudlet return an area with an empty name and an ID of 0 included in it, you should ignore that.
 +
</div></div></div>
  
: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: [[#getAreaTableSwap|getAreaTableSwap()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getAreaUserData(34, "country"))
+
-- example function that returns the area ID for a given area
-- might produce --
 
"Andor"
 
</syntaxhighlight>
 
  
{{note}}
+
function findAreaID(areaname)
 +
  local list = getAreaTable()
  
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]], [[#setAreaUserData|setAreaUserData()]]
+
  -- iterate over the list of areas, matching them with substring match.
 
+
  -- if we get match a single area, then return it's ID, otherwise return
==getCustomEnvColorTable==
+
  -- 'false' and a message that there are than one are matches
;envcolors = getCustomEnvColorTable()
+
  local returnid, fullareaname
 +
  for area, id in pairs(list) do
 +
    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
  
:Returns a table with customized environments, where the key is the environment ID and the value is a indexed table of rgb values.
+
-- sample use:
: See also: [[#setCustomEnvColor|setCustomEnvColor()]]
+
local id, msg = findAreaID("blahblah")
 
+
if id then
;Example
+
  echo("Found a matching ID: " .. id)
<syntaxhighlight lang="lua">
+
elseif not id and msg then
{
+
   echo("ID not found: " .. msg)
   envid1 = {r,g,b},
+
else
   envid2 = {r,g,b}
+
   echo("No areas matched the query.")
}
+
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getCustomLines==
+
==getAreaTableSwap==
;lineTable = getCustomLines(roomID)
+
;areaTable = getAreaTableSwap()
: See also: [[#addCustomLine|addCustomLine()]]
 
  
:Returns a table including all the details of the custom exit lines, if any, for the room with the id given.
+
: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.
 +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Historical Version Note</div>
 +
<div class="mw-collapsible-content">
 +
{{Note}} Some older versions of Mudlet return an area with an empty name and an ID of 0 included in it, you should ignore that.
 +
</div></div></div>
 +
 
 +
==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
 
;Parameters
Line 730: Line 890:
 
: Room ID to return the custom line details of.
 
: Room ID to return the custom line details of.
  
{{note}}
+
{{MudletVersion|3.0.}}
Available since Mudlet 3.0.
 
  
 
;Example
 
;Example
Line 778: Line 937:
 
       }
 
       }
 
     }
 
     }
 +
  }
 +
}
 +
</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 } }
 
   }
 
   }
 
}
 
}
Line 810: Line 1,005:
 
;stubs = getExitStubs(roomid)
 
;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.
+
: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. Returns nil plus error message of called on a non-existent room.
 +
 
 +
The directions numbers can be deciphered using this table;
 +
<syntaxhighlight lang="lua">
 +
  local stubmap = {
 +
      [1] = "north",  [2] = "northeast",  [3] = "northwest",  [4] = "east",
 +
      [5] = "west",  [6] = "south",      [7] = "southeast",  [8] = "southwest",
 +
      [9] = "up",    [10] = "down",      [11] = "in",        [12] = "out",
 +
      [13] = "northup", [14] = "southdown", [15] = "southup", [16] = "northdown",
 +
      [17] = "eastup", [18] = "westdown", [19] = "westup",    [20] = "eastdown"
 +
  }
 +
</syntaxhighlight>
  
 
: See also: [[#setExitStub|setExitStub()]], [[#connectExitStub|connectExitStub()]], [[#getExitStubs1|getExitStubs1()]]
 
: See also: [[#setExitStub|setExitStub()]], [[#connectExitStub|connectExitStub()]], [[#getExitStubs1|getExitStubs1()]]
Line 820: Line 1,026:
 
for i = 0, #stubs do print(stubs[i]) end
 
for i = 0, #stubs do print(stubs[i]) end
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Historical Version Note</div>
 +
<div class="mw-collapsible-content">
 
{{note}} 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.
 
{{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.
 +
</div></div></div>
  
 
==getExitStubs1==
 
==getExitStubs1==
Line 852: Line 1,061:
 
: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.
 
: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.
  
{{note}}
+
{{MudletVersion|3.11}}
Available since Mudlet 3.11
 
  
 
;Parameters
 
;Parameters
Line 888: Line 1,096:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Available in Mudlet 3.3
+
{{MudletVersion|3.3}}
  
 
==getMapLabel==
 
==getMapLabel==
;labelinfo = getMapLabels(areaID, labelID)
+
;labelinfo = getMapLabel(areaID, labelID or labelText)
  
:Returns a key-value table describing that particular label in an area. Keys it contains are the ''X'', ''Y'', ''Z'' coordinates, ''Height'' and ''Width'', and the ''Text'' it contains. If the label is an image label, then ''Text'' will be set to the ''no text'' string.
+
: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: [[#createMapLabel|createMapLabel()]], [[#getMapLabels|getMapLabels()]]
+
:''BgColor'' and ''FgColor'' are tables with ''r'',''g'',''b'' keys, each holding ''0-255'' color component value.
  
;Example
+
:''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
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
lua getMapLabels(1658987)
+
lua getMapLabels(52)
table {
+
{
   1: 'no text'
+
   "no text",
   0: 'test'
+
   [0] = "test"
 
}
 
}
  
lua getMapLabel(1658987, 0)
+
lua getMapLabel(52, 0)
table {
+
{
   'Y': -2
+
   Y = -2,
   'X': -8
+
   X = -8,
   'Z': 11
+
   Z = 11,
   'Height': 3.9669418334961
+
   Height = 3.9669418334961,
   'Text': 'test'
+
   Text = "test",
   'Width': 8.6776866912842
+
   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(1658987, 1)
+
lua getMapLabel(52, "no text")
table {
+
{
   'Y': 8
+
   Y = 8,
   'X': -15
+
   X = -15,
   'Z': 11
+
   Z = 11,
   'Height': 7.2520666122437
+
   Height = 7.2520666122437,
   'Text': 'no text'
+
   Text = "no text"
   'Width': 11.21900844574
+
   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>
 
</syntaxhighlight>
  
Line 932: Line 1,170:
  
 
: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.
 
: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()]]
+
: See also: [[#createMapLabel|createMapLabel()]], [[#getMapLabel|getMapLabel()]], [[#deleteMapLabel|deleteMapLabel()]]
  
 
;Example
 
;Example
Line 950: Line 1,189:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getMapUserData==
+
==getMapMenus==
;getMapUserData( key )
+
;getMapMenus()
 
 
;Parameters
 
* ''key:''
 
: string used as a key to select the data stored in the map as a whole.
 
  
: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.
+
: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>.
 +
: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.
  
: See also: [[#getAllMapUserData|getAllMapUserData()]], [[#setMapUserData|setMapUserData()]]
+
: See also: [[#addMapMenu|addMapMenu()]], [[#addMapEvent|addMapEvent()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getMapUserData("last updated"))
+
-- given the following menu structure:
--might result in:--
+
top-level
"December 5, 2020"
+
  menu1
 +
    menu1.1
 +
      action1.1.1
 +
    menu1.2
 +
      action1.2.1
 +
  menu2
 +
 
 +
getMapMenus() -- will return:
 +
{
 +
  menu2 = "top-level",
 +
  menu1.2 = "menu1",
 +
  menu1.1 = "menu1",
 +
  menu1 = "top-level"
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Available in Mudlet 3.0
+
==getMapSelection==
 +
; getMapSelection()
  
==getPath==
+
:Returns a table containing details of the current mouse selection in the 2D mapper.
;getPath(roomID from, roomID to)
+
 
 +
:Reports on one or more rooms being selected (i.e. they are highlighted in orange).
  
: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.
+
: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.
  
;Example
+
; Example - several rooms selected
 +
<syntaxhighlight lang="lua">
 +
display(getMapSelection())
 +
{
 +
  center = 5013,
 +
  rooms = {
 +
    5011,
 +
    5012,
 +
    5013,
 +
    5014,
 +
    5018,
 +
    5019,
 +
    5020
 +
  }
 +
}
 +
</syntaxhighlight>
 +
; Example - one room selected
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- check if we can go to room 155 from room 34 - if yes, go to it
+
display(getMapSelection())
if getPath(34,155) then
+
{
   gotoRoom(155)
+
  center = 5013,
else
+
   rooms = {
   echo("\nCan't go there!")
+
    5013
end
+
   }
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
; Example - no or something other than a room selected
==getPlayerRoom==
 
;roomID = getPlayerRoom()
 
 
 
:Returns the current player location as set by [[#centerview|centerview()]].
 
 
 
: See also: [[#centerview|centerview]]
 
 
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display("We're currently in "..getRoomName(getPlayerRoom())
+
display(getMapSelection())
 +
{
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Available in Mudlet 3.14
+
{{MudletVersion|3.17}}
  
==getRoomArea==
+
==getMapUserData==
;areaID = getRoomArea(roomID)
+
;getMapUserData( key )
 +
 
 +
;Parameters
 +
* ''key:''
 +
: string used as a key to select the data stored in the map as a whole.
  
: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.
+
: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.
  
{{note}} If the room ID does not exist, this function will raise an error.
+
: See also: [[#getAllMapUserData|getAllMapUserData()]], [[#setMapUserData|setMapUserData()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display("Area ID of room #100 is: "..getRoomArea(100))
+
display(getMapUserData("last updated"))
 +
--might result in:--
 +
"December 5, 2020"
 +
</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.
  
display("Area name for room #100 is: "..getRoomAreaName(getRoomArea(100)))
+
:See also: [[Manual:Mapper_Functions#setMapZoom|setMapZoom()]].
</syntaxhighlight>
 
  
==getRoomAreaName==
+
{{MudletVersion| 4.17.0}}
;getRoomAreaName(areaID or areaName)
 
  
:Returns the area name for a given area id; or the area id for a given area name.
+
;Parameters
 +
* ''areaID:''
 +
: Area ID number to get the 2D zoom for (''optional'', the function works on the area currently being viewed if this is omitted).
  
{{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.
+
;Returns
 +
* A floating point number on success
 +
* ''nil'' and an error message on failure.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
echo(string.format("room id #455 is in %s.", getRoomAreaName(getRoomArea(455))))
+
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>
 
</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''.
  
==getRoomChar==
+
==getPath==
;getRoomChar(roomID)
+
;getPath(roomID from, roomID to)
  
:Returns the single ASCII character that forms the ''symbol'' for the given room id.
+
: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.
  
: '''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.
 
  
==getRoomCoordinates==
+
: See also: [[Manual:Lua_Functions#translateTable|translateTable()]]
;x, y, z = getRoomCoordinates(room ID)
 
 
 
:Returns the room coordinates of the given room ID.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local x,y,z = getRoomCoordinates(roomID)
+
-- check if we can go to room 155 from room 34 - if yes, go to it
echo("Room Coordinates for "..roomID..":")
+
if getPath(34,155) then
echo("\n    X:"..x)
+
  gotoRoom(155)
echo("\n    Y:"..y)
+
else
echo("\n    Z:"..z)
+
  echo("\nCan't go there!")
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomEnv==
+
==getPlayerRoom==
;envID = getRoomEnv(roomID)
+
;getPlayerRoom()
 +
 
 +
:Returns the current player location as set by [[#centerview|centerview()]].
  
: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.
+
: See also: [[#centerview|centerview]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
funtion checkID(id)
+
display("We're currently in " .. getRoomName(getPlayerRoom()))
  echo(strinf.format("The env ID of room #%d is %d.\n", id, getRoomEnv(id)))
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== getRoomExits ==
+
{{MudletVersion|3.14}}
;getRoomExits (roomID)
+
 
:Returns the currently known non-special exits for a room in an key-index form: ''exit = exitroomid''.
+
==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.
  
: See also: [[#getSpecialExits|getSpecialExits()]]
+
{{note}} If the room ID does not exist, this function will raise an error.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
table {
+
display("Area ID of room #100 is: "..getRoomArea(100))
  'northwest': 80
+
 
  'east': 78
+
display("Area name for room #100 is: "..getRoomAreaName(getRoomArea(100)))
}
 
 
</syntaxhighlight>
 
</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):
+
==getRoomAreaName==
 +
;getRoomAreaName(areaID or areaName)
  
<syntaxhighlight lang="lua">
+
:Returns the area name for a given area id; or the area id for a given area name.
local exits = getRoomExits(mycurrentroomid)
 
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==
+
{{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.
;roomHash = getRoomHashByID(roomID)
 
  
:Returns a room hash that is associated with a given room ID in the mapper. This is primarily for MUDs 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.
+
;Example
 
+
<syntaxhighlight lang="lua">
: See also: [[#getRoomIDbyHash|getRoomIDbyHash()]]
+
echo(string.format("room id #455 is in %s.", getRoomAreaName(getRoomArea(455))))
{{note}} Available since Mudlet 3.13.0
+
</syntaxhighlight>
 +
 
 +
 
 +
==getRoomChar==
 +
;getRoomChar(roomID)
 +
 
 +
: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==
 +
;r,g,b = getRoomCharColor(roomID)
 +
 
 +
:Returns the color of the Room Character as a set of r,g,b color coordinates.
 +
 
 +
;See also: [[Manual:Lua_Functions#setRoomCharColor|setRoomCharColor()]], [[Manual:Lua_Functions#getRoomChar|getRoomChar()]]
 +
 
 +
;Parameters
 +
* ''roomID:''
 +
: The room ID to get the room character color from
  
{{note}} This operation is more expensive than [[#getRoomIDbyHash|getRoomIDbyHash()]] as it iterates over all rooms.
+
;Returns
 +
* The color as 3 separate numbers, red, green, and blue from 0-255
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
    for id,name in pairs(getRooms()) do
+
-- gets the color of the room character set on room 12345. If no room character is set the default 'color' is 0,0,0
        local h = getRoomUserData(id, "herbs")
+
local r,g,b = getRoomCharColor(12345)
        if h ~= "" then
+
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>.\")
            echo(string.format([[["%s"] = "%s",]], getRoomHashByID(id), h))
 
            echo("\n")
 
        end
 
    end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomIDbyHash==
+
==getRoomCoordinates==
;roomID = getRoomIDbyHash(hash)
+
;x,y,z = getRoomCoordinates(roomID)
  
:Returns a room ID that is associated with a given hash in the mapper. This is primarily for MUDs that make use of hashes instead of room IDs (like [http://avalon.mud.de/index.php?enter=1 Avalon.de] MUD). ''-1'' is returned if no room ID matches the hash.
+
:Returns the room coordinates of the given room ID.
  
: See also: [[#getRoomHashByID|getRoomHashByID()]]
+
;See also: [[Manual:Lua_Functions#setRoomCoordinates|setRoomCoordinates()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- example taken from http://forums.mudlet.org/viewtopic.php?f=13&t=2177
+
local x,y,z = getRoomCoordinates(roomID)
_id1 = getRoomIDbyHash( "5dfe55b0c8d769e865fd85ba63127fbc" );
+
echo("Room Coordinates for "..roomID..":")
if _id1 == -1 then
+
echo("\n    X:"..x)
   _id1 = createRoomID()
+
echo("\n    Y:"..y)
   setRoomIDbyHash( _id1, "5dfe55b0c8d769e865fd85ba63127fbc" )
+
echo("\n    Z:"..z)
  addRoom( _id )
+
</syntaxhighlight>
  setRoomCoordinates( _id1, 0, 0, -1 )
+
 
 +
<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
 +
  return t
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomName==
+
==getRoomEnv==
;roomName = getRoomName(roomID)
+
;envID = getRoomEnv(roomID)
  
:Returns the room name for a given room id.
+
: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
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
echo(string.format("The name of the room id #455 is %s.", getRoomName(455))
+
function checkID(id)
 +
  echo(string.format("The env ID of room #%d is %d.\n", id, getRoomEnv(id)))
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRooms==
+
== getRoomExits ==
;rooms = getRooms()
+
;getRoomExits (roomID)
 +
:Returns the currently known non-special exits for a room in an key-index form: ''exit = exitroomid''.
  
:Returns the list of '''all''' rooms in the map in the whole map in roomid - room name format.
+
: See also: [[#getSpecialExits|getSpecialExits()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- simple, raw viewer for rooms in the world
+
{
display(getRooms())
+
  south = 143,
 +
  west = 432
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomsByPosition==
+
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):
;roomTable = getRoomsByPosition(areaID, x,y,z)
+
 
 +
<syntaxhighlight lang="lua">
 +
local exits = getRoomExits(mycurrentroomid)
 +
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==
 +
;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.
  
: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.
+
: See also: [[#getRoomIDbyHash|getRoomIDbyHash()]]
 +
{{MudletVersion|3.13.0}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- sample alias to determine a room nearby, given a relative direction from the current room
+
    for id,name in pairs(getRooms()) do
 +
        local h = getRoomUserData(id, "herbs")
 +
        if h ~= "" then
 +
            echo(string.format([[["%s"] = "%s",]], getRoomHashByID(id), h))
 +
            echo("\n")
 +
        end
 +
    end
 +
</syntaxhighlight>
 +
 
 +
==getRoomIDbyHash==
 +
;roomID = getRoomIDbyHash(hash)
  
local otherroom
+
: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.
if matches[2] == "" then
 
  local w = matches[3]
 
  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)
+
: See also: [[#getRoomHashByID|getRoomHashByID()]]
  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)))
+
;Example
 
+
<syntaxhighlight lang="lua">
  if not otherroom then
+
-- example taken from http://forums.mudlet.org/viewtopic.php?f=13&t=2177
    mmp.echo("There isn't a room to the "..w.." that I see - try with an exact room id.") return
+
local id = getRoomIDbyHash("5dfe55b0c8d769e865fd85ba63127fbc")
   else
+
if id == -1 then
    mmp.echo("The room "..w.." of us has an ID of "..otherroom)
+
  id = createRoomID()
   end
+
   setRoomIDbyHash(id, "5dfe55b0c8d769e865fd85ba63127fbc")
 +
   addRoom(id)
 +
  setRoomCoordinates(id, 0, 0, -1)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getRoomUserData==
+
==getRoomName==
;dataText = getRoomUserData(roomID, key)
+
;getRoomName(roomID)
  
: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.
+
:Returns the room name for a given room id.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getRoomUserData(341, "visitcount"))
+
echo(string.format("The name of the room id #455 is %s.", getRoomName(455))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} ''code around 3.0 preview versions "delta" and "epsilon" were revised and would return both a Lua'' nil ''and an error message should the roomID not actually exist or if the key was not found in the user data for that room. This would break existing scripts that relied upon getting an empty string i.e. "" in either of those case even though it '''is''' possible to store such a string against a key in the room user data. '''This has now been changed back to restore the prior behavior when ''getRoomUserData'' is provided with two arguments'''; new scripts are instead recommended to use:
+
==getRooms==
 +
;rooms = getRooms()
 +
 
 +
:Returns the list of '''all''' rooms in the map in the whole map in roomid - room name format.
  
:;getRoomUserData(roomID, key, enableFullErrorReporting)
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- simple, raw viewer for rooms in the world
 +
display(getRooms())
  
::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.
+
-- iterate over all rooms in code
 +
for id,name in pairs(getRooms()) do
 +
  print(id, name)
 +
end
 +
</syntaxhighlight>
  
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
+
==getRoomsByPosition==
 +
;roomTable = getRoomsByPosition(areaID, x,y,z)
  
;Example
+
: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.
<!-- 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()]]
+
{{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.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
display(getRoomUserDataKeys(3441))
+
-- sample alias to determine a room nearby, given a relative direction from the current room
--might result in:--
 
{
 
  "description",
 
  "doorname_up",
 
}
 
</syntaxhighlight>
 
  
{{note}} Available since Mudlet 3.0.
+
local otherroom
 
+
if matches[2] == "" then
==getRoomWeight==
+
  local w = matches[3]
;room weight = getRoomWeight(roomID)
+
  local ox, oy, oz, x,y,z = getRoomCoordinates(mmp.currentroom)
 
+
  local has = table.contains
:Returns the weight of a room. By default, all new rooms have a weight of 1.
+
  if has({"west", "left", "w", "l"}, w) then
: See also: [[#setRoomWeight|setRoomWeight()]]
+
    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
  
;Example
+
  otherroom = select(2, next(getRoomsByPosition(carea,x,y,z)))
<syntaxhighlight lang="lua">
+
 
display("Original weight of room 541: "..getRoomWeight(541)
+
  if not otherroom then
setRoomWeight(541, 3)
+
    mmp.echo("There isn't a room to the "..w.." that I see - try with an exact room id.") return
display("New weight of room 541: "..getRoomWeight(541)
+
  else
 +
    mmp.echo("The room "..w.." of us has an ID of "..otherroom)
 +
  end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getSpecialExits==
+
==getRoomUserData==
;exits = getSpecialExits(roomID)
+
;getRoomUserData(roomID, key)
  
:Returns a roomid - command table of all special exits in the room. If there are no special exits in the room, the table returned will be empty.
+
: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.
 
 
: See also: [[#getRoomExits|getRoomExits()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
getSpecialExits(1337)
+
display(getRoomUserData(341, "visitcount"))
 
 
-- results in:
 
--[[
 
table {
 
  12106: 'faiglom nexus'
 
}
 
]]
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getSpecialExitsSwap==
+
:;getRoomUserData(roomID, key, enableFullErrorReporting)
;exits = getSpecialExitsSwap(roomID)
 
  
:Very similar to [[#getSpecialExits|getSpecialExits()]] function, but returns the rooms in the command - roomid style.
+
::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.
  
==gotoRoom==
+
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
;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 :(".
 
  
==hasExitLock==
+
;Example
;status = hasExitLock(roomID, direction)
+
<!-- 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!''
  
: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").
+
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
  
; Example
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- check if the east exit of room 1201 is locked
+
display(getRoomUserDataKeys(3441))
display(hasExitLock(1201, 4))
+
--might result in:--
display(hasExitLock(1201, "e"))
+
{
display(hasExitLock(1201, "east"))
+
  "description",
 +
  "doorname_up",
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See also: [[#lockExit|lockExit()]]
+
{{MudletVersion|3.0}}
  
==hasSpecialExitLock==
+
==getRoomWeight==
;status = hasSpecialExitLock(from roomID, to roomID, command)
+
;getRoomWeight(roomID)
  
:Returns ''true'' or ''false'' depending on whenever a given exit leading out from a room is locked. ''command'' is the action to take to get through the gate.
+
:Returns the weight of a room. By default, all new rooms have a weight of 1.
 +
: See also: [[#setRoomWeight|setRoomWeight()]]
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- lock a special exit from 17463 to 7814 that uses the 'enter feather' command
+
display("Original weight of room 541: "..getRoomWeight(541))
lockSpecialExit(17463, 7814, 'enter feather', true)
+
setRoomWeight(541, 3)
 
+
display("New weight of room 541: "..getRoomWeight(541))
-- see if it is locked: it will say 'true', it is
 
display(hasSpecialExitLock(17463, 7814, 'enter feather'))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==highlightRoom==
+
==getSpecialExits==
;highlightRoom( roomID, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)
+
;exits = getSpecialExits(roomID[, listAllExits])
 
 
:Highlights a room with the given color, which will override it's 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.
 
  
 
;Parameters
 
;Parameters
* ''roomID''
+
* ''roomID:''
: ID of the room to be colored.
+
: Room ID to return the special exits of.
* ''color1Red, color1Green, color1Blue''
+
* ''listAllExits:''
: RGB values of the first color.
+
: In the case where there is more than one special exit to the same room ID list all of them.
* ''color2Red, color2Green, color2Blue''
 
: RGB values of the second color.
 
* ''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()]]
+
: 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
 
+
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
{{note}} Available since Mudlet 2.0 final release
+
<div style="font-weight:bold;line-height:1.6;">Historical Version Note</div>
 +
<div class="mw-collapsible-content">
 +
: (Since ''TBA'') In the case where there is more than one special exit to the same room ID list all of them.
 +
: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.
 +
</div></div></div>
 +
: See also: [[#getRoomExits|getRoomExits()]]
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- color room #351 red to blue
+
-- There are three special exits from 1337 to the room 42:
local r,g,b = unpack(color_table.red)
+
-- "climb down ladder" which is locked and has an exit weight of 10
local br,bg,bb = unpack(color_table.blue)
+
-- "step out window" which is unlocked and has an exit weight of 20
highlightRoom(351, r,g,b,br,bg,bb, 1, 255, 255)
+
-- "jump out window" which is unlocked and has an exit weight of 990
</syntaxhighlight>
+
getSpecialExits(1337)
  
==getAllRoomEntrances==
+
-- In 4.10.1 and before this could results in:
;exitsTable = getAllRoomEntrances(roomID)
+
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"}
 +
}
  
: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.
+
-- From TBA this will return:
 +
table {
 +
  42 = {"step out window" = "0"},
 +
  666 = {"dive into pit" = "1"}
 +
}
  
{{note}} Available since Mudlet 3.0.
+
-- From TBA, with the second argument as true, this gives:
 
+
getSpecialExits(1337, true)
;Example
+
table {
<syntaxhighlight lang="lua">
+
  42 = {"step out window" = "0",
-- print the list of rooms that have exits leading into room 512
+
        "climb down ladder" = "1",
for _, roomid in ipairs(getAllRoomEntrances(512)) do
+
        "jump out window" = "0"},
   print(roomid)
+
   666 = {"dive into pit" = "1"}
end
+
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See also: [[#getRoomExits|getRoomExits()]]
+
==getSpecialExitsSwap==
 +
;getSpecialExitsSwap(roomID)
  
==loadMap==
+
:Very similar to [[#getSpecialExits|getSpecialExits()]] function, but returns the rooms in the command - roomid style.
;boolean = loadMap(file location)
 
  
: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 download-able maps for their MUDs.  
+
==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 :(".
  
:Returns a boolean for whenever the loading succeeded. Note that the mapper must be open, or this will fail.
+
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)
  
: See also: [[#saveMap|saveMap()]]
+
: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">
  loadMap("/home/user/Desktop/Mudlet Map.dat")
+
-- check if the east exit of room 1201 is locked
 +
display(hasExitLock(1201, 4))
 +
display(hasExitLock(1201, "e"))
 +
display(hasExitLock(1201, "east"))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==lockExit==
+
: See also: [[#lockExit|lockExit()]]
;lockExit(roomID, direction, lockIfTrue)
+
 
 +
==hasSpecialExitLock==
 +
;hasSpecialExitLock(from roomID, to roomID, moveCommand)
  
:Locks a given exit from a room (which means that unless all exits in the incoming room are locked, it'll still be accessible). Direction can be specified as a number, short direction name ("nw") or long direction name ("northwest").
+
: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.
  
: See also: [[#hasExitLock|hasExitLock()]]
+
See also: [[#lockSpecialExit|lockSpecialExit()]]
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- lock the east exit of room 1201 so we never path through it
+
-- lock a special exit from 17463 to 7814 that uses the 'enter feather' command
lockExit(1201, 4, true)
+
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>
  
==lockRoom==
+
==highlightRoom==
;lockRoom (roomID, lockIfTrue)
+
;highlightRoom( roomID, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)
 +
 
 +
: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.
  
:Locks a given room id from future speed walks (thus the mapper will never path through that room).
+
;Parameters
: See also: [[#roomLocked | roomLocked()]]
+
* ''roomID''
 +
: ID of the room to be colored.
 +
* ''color1Red, color1Green, color1Blue''
 +
: RGB values of the first color.
 +
* ''color2Red, color2Green, color2Blue''
 +
: RGB values of the second color.
 +
* ''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()]]
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
lockRoom(1, true) -- locks a room if from being walked through when speedwalking.
+
-- simple example:
lockRoom(1, false) -- unlocks the room, adding it back to possible rooms that can be walked through.
+
highlightRoom(351, 255,0,0, 0,0,255, 1, 255, 255)
 +
 
 +
-- another example, 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>
 
</syntaxhighlight>
  
==lockSpecialExit==
+
==killMapInfo==
;lockSpecialExit (from roomID, to roomID, special exit command, lockIfTrue)
+
;killMapInfo(label)
 +
 
 +
Delete a map info contributor entirely - it will be not available anymore.
  
: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).
+
;Parameters
: See also: [[#hasSpecialExitLock | hasSpecialExitLock()]], [[#lockExit | lockExit()]], [[#lockRoom | lockRoom()]]
+
* ''label:''
 +
: Name under which map info to be removed was registered.
  
;Example
+
: See also: [[#registerMapInfo|registerMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#disableMapInfo|disableMapInfo()]]
<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
+
{{MudletVersion|4.11}}
lockSpecialExit(1,2,'enter gate', false) -- unlocks the said exit
+
 
</syntaxhighlight>
+
==loadJsonMap==
 +
; loadJsonMap(pathFileName)
 +
 
 +
; Parameters:
 +
 
 +
* ''pathFileName'' a string that is an absolute path and file name to read the data from.
  
==resetRoomArea==
+
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.
;resetRoomArea (areaID)
 
  
: 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: [[#saveJsonMap|saveJsonMap()]]
  
: See also: [[#setRoomArea | setRoomArea()]], [[#getRoomArea | getRoomArea()]]
+
Returns:
 +
* ''true'' on success
 +
* ''nil'' and an error message on failure.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
resetRoomArea(3143)
+
loadJsonMap(getMudletHomeDir() .. "/map.json")
 +
 
 +
true
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==removeMapEvent==
+
{{MudletVersion|4.11.0}}
;removeMapEvent (event name)
 
  
:Removes the given menu entry from a mappers right-click menu. You can add custom ones with [[#addMapEvent | addMapEvent()]].
+
==loadMap==
: See also: [[#addMapEvent | addMapEvent()]], [[#addMapMenu | addMapMenu()]], [[#getMapEvents | getMapEvents()]]
+
;loadMap(file location)
  
;Example
+
: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.
<syntaxhighlight lang="lua">
 
addMapEvent("room a", "onFavorite") -- add one to the general menu
 
removeMapEvent("room a") -- removes the said menu
 
</syntaxhighlight>
 
  
==removeCustomLine==
+
:Returns a boolean for whenever the loading succeeded. Note that the mapper must be open, or this will fail.
;removeCustomLine(roomID, direction)
 
  
:Removes the custom exit line that's associated with a specific exit of a room.
+
:Using no arguments will load the last saved map.
:See also: [[#addCustomLine|addCustomLine()]], [[#getCustomLines|getCustomLines()]]
 
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- remove custom exit line that starts in room 315 going north
+
  loadMap("/home/user/Desktop/Mudlet Map.dat")
removeCustomLine(315, "n")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==removeSpecialExit==
+
{{Note}} A file name ending with <code>.xml</code> will indicate the XML format.
;removeSpecialExit(roomID, command)  
+
 
 +
==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").
  
:Removes the special exit which is accessed by ''command'' from the room with the given ''roomID''.
+
: See also: [[#hasExitLock|hasExitLock()]]
: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
+
-- lock the east exit of room 1201 so we never path through it
removeSpecialExit(1, "pull rope") -- removes the exit again
+
lockExit(1201, 4, true)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==roomExists==
+
==lockRoom==
;roomExists(roomID)
+
;lockRoom (roomID, lockIfTrue)
  
:Returns a boolean true/false depending if the room with that ID exists (is created) or not.
+
:Locks a given room id from future speed walks (thus the mapper will never path through that room).
 
+
: See also: [[#roomLocked | roomLocked()]]
==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"))
+
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>
 
</syntaxhighlight>
  
==saveMap==
+
==lockSpecialExit==
;saveMap(location)
+
;lockSpecialExit (from roomID, to roomID, special exit command, lockIfTrue)
  
: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.
+
: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()]]
: See also: [[#loadMap|loadMap()]]
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local savedok = saveMap(getMudletHomeDir().."/my fancy map.dat")
+
lockSpecialExit(1,2,'enter gate', true) -- locks the special exit that does 'enter gate' to get from room 1 to room 2
if not savedok then
+
lockSpecialExit(1,2,'enter gate', false) -- unlocks the said exit
  echo("Couldn't save :(\n")
 
else
 
  echo("Saved fine!\n")
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==searchAreaUserData==
+
==moveMapWidget==
: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.
+
;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.
  
==searchRoom==
+
: See also: [[#closeMapWidget|closeMapWidget()]], [[#moveMapWidget|moveMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
;searchRoom (room name / room number)
 
  
: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''.
+
{{MudletVersion|4.7}}
:If you pass it a number instead of a string, it'll act like [[#getRoomName|getRoomName()]] and return you the room name.
 
  
;Example
+
;Parameters
<syntaxhighlight lang="lua">
+
{{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)
display(searchRoom("master"))
+
* ''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)
  [17463] = 'in the branches of the Master Ravenwood'
+
{{note}} If 4 parameters are given the map window will be created in floating state
  [3652] = 'master bedroom'
+
* ''Xpos:''
  [10361] = 'Hall of Cultural Masterpieces'
+
: X position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
  [6324] = 'Exhibit of the Techniques of the Master Artisans'
+
* ''Ypos:''
  [5340] = 'office of the Guildmaster'
+
: Y position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
  [2004] = 'office of the guildmaster'
+
* ''width:''
  [14457] = 'the Master Gear'
+
: The width map window, in pixels. Passed as an integer number.
  [1337] = 'before the Master Ravenwood Tree'
+
* ''height:''
}
+
: The height map window, in pixels. Passed as an integer number.
</syntaxhighlight>
 
  
If no rooms are found, then an empty table is returned.
+
==pauseSpeedwalk==
 +
;pauseSpeedwalk()
  
{{note}} Additional parameters are available since Mudlet 3.0:
+
:Pauses a speedwalk started using [[#speedwalk|speedwalk()]]
  
;searchRoom (room name, [case-sensitive [, exact-match]])
+
: See also: [[#speedwalk|speedwalk()]], [[#stopSpeedwalk|stopSpeedwalk()]], [[#resumeSpeedwalk|resumeSpeedwalk()]]
  
;Additional Parameters
+
{{MudletVersion|4.13}}
* ''case-sensitive:''
 
: If true forces a case-sensitive search to be done on with the supplied room name argument, if false case is not considered.
 
* ''exact-match:''
 
: If true forces an exact match rather than a sub-string match, with a case sensitivity as set by previous option.
 
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- shows all rooms containing these words in any case: --
+
local ok, err = pauseSpeedwalk()
display(searchRoom("North road",false,false))
+
if not ok then
{
+
   debugc(f"Error: unable to pause speedwalk because {err}\n")
   [3114] = "Bend in North road",
+
   return
   [3115] = "North road",
+
end
  [3116] = "North Road",
+
</syntaxhighlight>
  [3117] = "North road",
 
  [3146] = "Bend in the North Road",
 
  [3088] = "The North Road South of Taren Ferry",
 
  [6229] = "Grassy Field By North Road"
 
}
 
  
-- shows all rooms containing these words in ONLY this case: --
+
==registerMapInfo==
display(searchRoom("North road",true,false))
+
;registerMapInfo(label, function)
{
 
  [3114] = "Bend in North road",
 
  [3115] = "North road",
 
  [3117] = "North road",
 
}
 
  
-- shows all rooms containing ONLY these words in any case: --
+
Adds an extra 'map info' to the mapper widget which can be used to display custom information.
lua searchRoom("North road",false,true)
 
{
 
  [3115] = "North road",
 
  [3116] = "North Road",
 
  [3117] = "North road"
 
}
 
  
-- shows all rooms containing ONLY these words in ONLY this case: --
+
: See also: [[#killMapInfo|killMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#disableMapInfo|disableMapInfo()]]
lua searchRoom("North road",true,true)
 
{
 
  [3115] = "North road",
 
  [3117] = "North road"
 
}
 
</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.
+
{{MudletVersion|4.11}}
  
==searchRoomUserData==
+
{{note}}
: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:
+
You can register multiple map infos - just give them unique names and toggle whichever ones you need.
  
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#setRoomUserData|setRoomUserData()]]
+
;Parameters
 +
* ''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.
  
;searchRoomUserData(key, value)
+
Callback function is called with following arguments:
 +
* ''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
  
:Reports a (sorted) list of all room ids with user data with the given "value" for the given (case sensitive) "key". Due to the lack of previous enforcement it is possible (though not recommended) to have a room user data item with an empty string "" as a key, this is handled correctly.
+
Callback needs to return following:
 +
* ''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")
 +
* ''isBold'' (optional) - true/false - determines whether text will be bold
 +
* ''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)
  
;searchRoomUserData(key)
+
{{note}}
 +
Map info is registered in disabled state, you need to enable it through script or by selecting checkbox under mapper.
  
:Reports a (sorted) list of the unique values from all rooms with user data with the given (case sensitive) "key".  Due to the lack of previous enforcement it is possible (though not recommended) to have a room user data item with an empty string "" as a key, this is handled correctly.
+
<syntaxhighlight lang="lua">
 +
registerMapInfo("My very own handler!", function(roomId, selectionSize, areaId, displayedArea)  
 +
  return string.format("RoomId: %d\nNumbers of room selected: %d\nAreaId: %d\nDisplaying area: %d", roomId, selectionSize, areaId, displayedArea),
 +
  true, true, 0, 255, 0
 +
end)
 +
enableMapInfo("My very own handler!")
 +
</syntaxhighlight>
  
;searchRoomUserData()
+
Example will display something like that:
  
:Reports a (sorted) list of the unique keys from all rooms with user data with any (case sensitive) "key", available since Mudlet 3.0.
+
[[File:Map-info-example.png]]
  
;Examples
+
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">
-- if I had stored the details of "named doors" as part of the room user data --
+
registerMapInfo("Alert", function()
display(searchRoomUserData("doorname_up"))
+
  if character.hp < 20 then
 +
    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
 +
  else
 +
    return "" -- will not return anything
 +
  end
 +
end)
 +
enableMapInfo("Alert")
 +
</syntaxhighlight>
 +
 
 +
==resumeSpeedwalk==
 +
;resumeSpeedwalk()
  
--[[ could result in a list:
+
:Continues a speedwalk paused using [[#pauseSpeedwalk|pauseSpeedwalk()]]
{
+
: See also: [[#speedwalk|speedwalk()]], [[#pauseSpeedwalk|pauseSpeedwalk()]], [[#stopSpeedwalk|stopSpeedwalk()]]
  "Eastgate",
 
  "Northgate",
 
  "boulderdoor",
 
  "chamberdoor",
 
  "dirt",
 
  "floorboards",
 
  "floortrap",
 
  "grate",
 
  "irongrate",
 
  "rockwall",
 
  "tomb",
 
  "trap",
 
  "trapdoor"
 
}]]
 
  
-- then taking one of these keys --
+
{{MudletVersion|4.13}}
display(searchRoomUserData("doorname_up","trapdoor"))
 
  
--[[ might result in a list:
+
<syntaxhighlight lang="lua">
{
+
local ok, err = resumeSpeedwalk()
  3441,
+
if not ok then
   6113,
+
   cecho(f"\n<red>Error:<reset> Problem resuming speedwalk: {err}\n")
   6115,
+
   return
  8890
+
end
}
+
cecho("\n<green>Successfully resumed speedwalk!\n")
]]</syntaxhighlight>
+
</syntaxhighlight>
  
{{note}} Available since Mudlet 3.0.
+
==removeCustomLine==
 +
;removeCustomLine(roomID, direction)
  
==setAreaName==
+
:Removes the custom exit line that's associated with a specific exit of a room.
;setAreaName(areaID or areaName, newName)
+
:See also: [[#addCustomLine|addCustomLine()]], [[#getCustomLines|getCustomLines()]]
  
:Names, or renames an existing area to the new name. The area must be created first with [[#addAreaName|addAreaName()]] and it must be unique.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- remove custom exit line that starts in room 315 going north
 +
removeCustomLine(315, "n")
 +
</syntaxhighlight>
  
{{note}} areaName is available since Mudlet 3.0.
+
==removeMapEvent==
 +
;removeMapEvent(event name)
  
:See also: [[#deleteArea|deleteArea()]], [[#addAreaName|addAreaName()]]
+
:Removes the given menu entry from a mappers right-click menu. You can add custom ones with [[#addMapEvent | addMapEvent()]].
 +
: See also: [[#addMapEvent | addMapEvent()]], [[#getMapEvents | getMapEvents()]], [[#removeMapMenu | removeMapMenu()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setAreaName(2, "My city")
+
addMapEvent("room a", "onFavorite") -- add one to the general menu
 +
removeMapEvent("room a") -- removes the said menu
 +
</syntaxhighlight>
  
-- available since Mudlet 3.0
+
==removeMapMenu==
setAreaName("My old city name", "My new city name")
+
;removeMapMenu(menu name)
</syntaxhighlight>
 
  
==setAreaUserData==
+
:Removes the given submenu from a mappers right-click menu. You can add custom ones with [[#addMapMenu | addMapMenu()]].
;setAreaUserData(areaID, key (as a string), value (as a string))
+
: See also: [[#addMapMenu | addMapMenu()]], [[#getMapMenus | getMapMenus()]], [[#removeMapEvent | removeMapEvent()]]
  
: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.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
addMapMenu("Test") -- add submenu to the general menu
 +
removeMapMenu("Test") -- removes that same menu again
 +
</syntaxhighlight>
  
:Returns true if successfully set.
+
==removeSpecialExit==
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#getAreaUserData|getAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]]
+
;removeSpecialExit(roomID, command)  
  
{{note}} Release (not Development) version 3.0 software made this function available, but was unable to load the prerequisite map formats 17 and 18 that can store map-level data - that had been fixed in Release 3.0.1 .
+
: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">
-- can use it to store extra area details...
+
addSpecialExit(1, 2, "pull rope") -- add a special exit from room 1 to room 2
setAreaUserData(34, "country", "Andor.")
+
removeSpecialExit(1, "pull rope") -- removes the exit again
 
 
-- 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(34, "some table")).ruler)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setCustomEnvColor==
+
==resetRoomArea==
;setCustomEnvColor(environmentID, r,g,b,a)
+
;resetRoomArea (roomID)
  
: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.
+
: 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: [[#getCustomEnvColorTable|getCustomEnvColorTable()]], [[#setRoomEnv|setRoomEnv()]]
 
  
{{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.
+
: See also: [[#setRoomArea | setRoomArea()]], [[#getRoomArea | getRoomArea()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setRoomEnv(571, 200) -- change the room's environment ID to something arbitrary, like 200
+
resetRoomArea(3143)
local r,g,b = unpack(color_table.blue)
 
setCustomEnvColor(200, r,g,b, 255) -- set the color of environmentID 200 to blue
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setDoor==
+
==resizeMapWidget==
;setDoor(roomID, exitCommand, doorStatus)
+
;resizeMapWidget(width, height)
 +
:resizes a map window with given width, height.
 +
: See also: [[#openMapWidget|openMapWidget()]], [[#closeMapWidget|closeMapWidget()]], [[#moveMapWidget|moveMapWidget()]]
  
:Creates or deletes a door in a room. Doors are purely visual - they don't affect pathfinding. You can use the information to change to adjust your speedwalking path based on the door information in a room, though.
+
{{MudletVersion|4.7}}
  
: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!''
+
;Parameters
 +
* ''width:''
 +
: The width of the map window, in pixels. Passed as an integer number.
 +
* ''height:''
 +
: The height of the map window, in pixels. Passed as an integer number.
  
: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).
+
==roomExists==
 +
;roomExists(roomID)
  
: See also: [[#getDoors|getDoors()]]
+
:Returns a boolean true/false depending if the room with that ID exists (is created) or not.
  
;Parameters
+
==roomLocked==
* ''roomID:''
+
;locked = roomLocked(roomID)
: Room ID to to create the door in.
 
* ''exitCommand:''
 
: 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.
 
 
 
* ''doorStatus:''
 
: 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).
 
  
 +
:Returns true or false whenever a given room is locked.
 +
: See also: [[#lockRoom|lockRoom()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- make a door on the east exit of room 4234 that is currently open
+
echo(string.format("Is room #4545 locked? %s.", roomLocked(4545) and "Yep" or "Nope"))
setDoor(4234, 'e', 1)
+
</syntaxhighlight>
 +
 
 +
==saveJsonMap==
 +
; saveJsonMap([pathFileName])
 +
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.
  
-- remove a door from room 923 that points north
+
: See also: [[#loadJsonMap|loadJsonMap()]]
setDoor(923, 'n', 0)
+
{{MudletVersion|4.11.0}}
</syntaxhighlight>
 
 
 
==setExit==
 
;setExit(from roomID, to roomID, direction)
 
  
: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.
+
; Parameters:
 +
* ''pathFileName'' (optional in Mudlet 4.12+): a string that is an absolute path and file name to save the data into.
  
:Returns ''false'' if the exit creation didn't work.
+
; Returns:
 +
* ''true'' on success
 +
* ''nil'' and an error message on failure.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- alias pattern: ^exit (\d+) (\d+) (\w+)$
+
saveJsonMap(getMudletHomeDir() .. "/map.json")
-- 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
+
true
  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:
+
==saveMap==
 +
;saveMap([location], [version])
  
<syntaxhighlight lang="lua">setExit(from roomID, -1, direction)</syntaxhighlight>
+
: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.
  
- which will delete an outgoing exit in the specified direction from a room.
+
;Parameters
 +
* ''location''
 +
: (optional) save the map to the given location if provided, or the default one otherwise.
 +
* ''version''
 +
: (optional) map version as a number to use when saving (Mudlet 3.17+)
  
==setExitStub==
+
: See also: [[#loadMap|loadMap()]]
;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.
+
;Example
 
+
<syntaxhighlight lang="lua">
;Parameters
+
local savedok = saveMap(getMudletHomeDir().."/my fancy map.dat")
* ''roomID:''
+
if not savedok then
: The room to place an exit stub in, as a number.
+
  echo("Couldn't save :(\n")
* ''direction:''
+
else
: The direction the exit stub should lead in - as ashort direction name ("nw"), long direction name ("northwest") or a number.
+
  echo("Saved fine!\n")
* ''set/unset:''
+
end
: A boolean to create or delete the exit stub.
 
  
: See also: [[#getExitStubs|getExitStubs()]], [[#connectExitStub|connectExitStub()]]
+
-- save with a particular map version
 +
saveMap(20)
 +
</syntaxhighlight>
  
;Example
+
==searchAreaUserData==
Create an exit stub to the south from room 8:
+
;searchAreaUserData(area number | area name[, case-sensitive [, exact-match]])
<syntaxhighlight lang="lua">
+
: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.
setExitStub(8, "s", true)
 
</syntaxhighlight>
 
  
How to delete all exit stubs in a room:
+
==searchRoom==
<syntaxhighlight lang="lua">
+
;searchRoom (room number | room name[, case-sensitive [, exact-match]])
for i,v in pairs(getExitStubs(roomID)) do
+
: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;
  setExitStub(roomID, v,false)
 
end
 
</syntaxhighlight>
 
  
==setExitWeight==
+
::If no rooms are found, then an empty table is returned.
;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.
+
: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.
  
;Parameters
+
;Examples
* ''roomID:''
+
<syntaxhighlight lang="lua">
: Room ID to to set the weight in.
+
-- show the behavior when given a room number:
* ''exitCommand:''
+
display(searchRoom(3088))
: 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 North Road South of Taren Ferry"
* ''weight:''
 
: 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.
 
  
: See also: [[#getExitWeights|getExitWeights()]]
+
-- 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.
  
==setGridMode==
+
-- shows all rooms containing the text in ONLY the letter-case provided:
;setGridMode(areaID, true/false)
+
display(searchRoom("North road",true,false))
 +
{
 +
  [3114] = "Bend in North road",
 +
  [3115] = "North road",
 +
  [3117] = "North road",
 +
}
  
: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.
+
-- shows all rooms containing ONLY that text in either letter-case:
:Returns true if the area exists, otherwise false.
+
lua searchRoom("North road",false,true)
 +
{
 +
  [3115] = "North road",
 +
  [3116] = "North Road",
 +
  [3117] = "North road"
 +
}
  
: See also: [[#getGridMode|getGridMode()]]
+
-- shows all rooms containing only and exactly the given text:
 
+
lua searchRoom("North road",true,true)
;Example
+
{
<syntaxhighlight lang="lua">
+
  [3115] = "North road",
setGridMode(55, true) -- set area with ID 55 to be in grid mode
+
  [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.
  
==setMapUserData==
+
==searchRoomUserData==  
;setMapUserData(key (as a string), value (as a string))
+
;searchRoomUserData([key, [value]])
 +
: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:
  
: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.
+
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#setRoomUserData|setRoomUserData()]]
  
:Returns true if successfully set.
+
;searchRoomUserData(key, value)
: See also: [[#clearMapUserData|clearMapUserData()]], [[#clearMapUserDataItem|clearMapUserDataItem()]], [[#getAllMapUserData|getAllMapUserData()]], [[#getMapUserData|getMapUserData()]]
 
  
{{note}} Release (not Development) version 3.0 software made this function available, but was unable to load the prerequisite map formats 17 and 18 that can store map-level data - that had been fixed in Release 3.0.1 .
+
:Reports a (sorted) list of all room ids with user data with the given "value" for the given (case sensitive) "key".  
  
;Example
+
;searchRoomUserData(key)
<syntaxhighlight lang="lua">
 
-- store general meta information about the map...
 
setMapUserData("game_name", "Achaea Mudlet map")
 
  
-- or who the author was
+
:Reports a (sorted) list of the unique values from all rooms with user data with the given (case sensitive) "key".
setMapUserData("author", "Bob")
 
  
-- can even store tables in it, using the built-in yajl.to_string function
+
;searchRoomUserData()
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>
 
  
==setMapZoom==
+
: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.
;setMapZoom(zoom)
 
  
:Zooms the map in to a given zoom level. '''1''' is the closest you can get, and anything higher than that zooms the map out. Call [[#centerview|centerview()]] after you set the zoom to refresh the map.
+
{{MudletVersion|3.0}}
  
;Example
+
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setMapZoom(10) -- zoom to a somewhat acceptable level, a bit big but easily visible connections
+
-- if I had stored the details of "named doors" as part of the room user data --
</syntaxhighlight>
+
display(searchRoomUserData("doorname_up"))
  
==setRoomArea==
+
--[[ could result in a list:
;setRoomArea(roomID, newAreaID or newAreaName)
+
{
 +
  "Eastgate",
 +
  "Northgate",
 +
  "boulderdoor",
 +
  "chamberdoor",
 +
  "dirt",
 +
  "floorboards",
 +
  "floortrap",
 +
  "grate",
 +
  "irongrate",
 +
  "rockwall",
 +
  "tomb",
 +
  "trap",
 +
  "trapdoor"
 +
}]]
  
: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.
+
-- then taking one of these keys --
 +
display(searchRoomUserData("doorname_up","trapdoor"))
  
: See also: [[#resetRoomArea|resetRoomArea()]]
+
--[[ might result in a list:
 
+
{
==setRoomChar==
+
  3441,
;setRoomChar(roomID, character)
+
  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.
  
: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, the symbol can be cleared by using "_" as the character.
+
:See also: [[#deleteArea|deleteArea()]], [[#addAreaName|addAreaName()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setRoomChar(431, "#")
+
setAreaName(2, "My city")
  
setRoomChar(123. "$")
+
-- available since Mudlet 3.0
 +
setAreaName("My old city name", "My new city name")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
:'''Since Mudlet version 3.8 :''' this facility has been extended:
+
==setAreaUserData==
:* 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.
+
;setAreaUserData(areaID, key (as a string), value (as a string))
:* 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 MUD 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 use 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()]]
+
: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.
  
==setRoomCoordinates==
+
:Returns true if successfully set.
;setRoomCoordinates(roomID, x, y, z)
+
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#getAreaUserData|getAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]]
 
 
:Sets the given room ID to be at the following coordinates visually on the map, where ''z'' is the up/down level.
 
  
{{note}} 0,0,0 is the center of the map.
+
{{MudletVersion|3.0}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- alias pattern: ^set rc (-?\d+) (-?\d+) (-?\d+)$
+
-- can use it to store extra area details...
local x,y,z = getRoomCoordinates(previousRoomID)
+
setAreaUserData(34, "country", "Andor.")
local dir = matches[2]
+
 
 +
-- 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>
 +
 
 +
==setCustomEnvColor==
 +
;setCustomEnvColor(environmentID, r,g,b,a)
  
if dir == "n" then
+
: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.
  y = y+1
+
: See also: [[#getCustomEnvColorTable|getCustomEnvColorTable()]], [[#setRoomEnv|setRoomEnv()]]
elseif dir == "ne" then
+
 
  y = y+1
+
{{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.
  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>
 
  
:You can make them relative as well:
+
[[File:Screenshot 20240305 115555.png|thumb|center|Default colour table for Mudlet mapper.]]
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- alias pattern: ^src (\w+)$
+
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>
  
local x,y,z = getRoomCoordinates(previousRoomID)
+
==setDoor==
local dir = matches[2]
+
;setDoor(roomID, exitCommand, doorStatus)
 +
 
 +
:Creates or deletes a door in a room. Doors are purely visual - they don't affect default pathfinding (use a custom script to overcome this). 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
 +
* ''roomID:''
 +
: Room ID to to create the door in.
 +
* ''exitCommand:''
 +
: 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.
  
if dir == "n" then
+
* ''doorStatus:''
  y = y+1
+
: 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).
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
+
-- make a door on the east exit of room 4234 that is currently open
 +
setDoor(4234, 'e', 1)
 +
 
 +
-- remove a door from room 923 that points north
 +
setDoor(923, 'n', 0)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setRoomIDbyHash==
+
==setExit==
;setRoomIDbyHash(roomID, hash)
+
;setExit(from roomID, to roomID, direction)
  
:Sets the hash to be associated with the given roomID. See also [[#getRoomIDbyHash|getRoomIDbyHash()]].
+
: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.
  
==setRoomName==
+
:Returns ''false'' if the exit creation didn't work.
;setRoomName(roomID, newName)
 
  
:Renames an existing room to a new name.
+
: See also: [[#addSpecialExit|addSpecialExit()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setRoomName(534, "That evil room I shouldn't visit again.")
+
-- alias pattern: ^exit (\d+) (\d+) (\w+)$
lockRoom(534, true) -- and lock it just to be safe
+
-- 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>
  
==setRoomUserData==
+
This function can also delete exits from a room if you use it like so:
;setRoomUserData(roomID, key (as a string), value (as a string))
+
 
 +
<syntaxhighlight lang="lua">setExit(from roomID, -1, direction)</syntaxhighlight>
  
: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.  
+
- which will delete an outgoing exit in the specified direction from a room.
  
:Returns true if successfully set.
+
==setExitStub==
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]]
+
;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.
  
;Example
+
;Parameters
<syntaxhighlight lang="lua">
+
* ''roomID:''
-- can use it to store room descriptions...
+
: The room to place an exit stub in, as a number.
setRoomUserData(341, "description", "This is a plain-looking room.")
+
* ''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.
  
-- or whenever it's outdoors or not...
+
: See also: [[#getExitStubs|getExitStubs()]], [[#connectExitStub|connectExitStub()]]
setRoomUserData(341, "ourdoors", "true")
 
  
-- how how many times we visited that room
+
;Example
local visited = getRoomUserData(341, "visitcount")
+
Create an exit stub to the south from room 8:
visited = (tonumber(visited) or 0) + 1
+
<syntaxhighlight lang="lua">
setRoomUserData(341, "visitcount", tostring(visited))
+
setExitStub(8, "s", true)
 +
</syntaxhighlight>
  
-- can even store tables in it, using the built-in yajl.to_string function
+
How to delete all exit stubs in a room:
setRoomUserData(341, "some table", yajl.to_string({name = "bub", age = 23}))
+
<syntaxhighlight lang="lua">
display("The denizens name is: "..yajl.to_value(getRoomUserData(341, "some table")).name)
+
for i,v in pairs(getExitStubs(roomID)) do
 +
  setExitStub(roomID, v,false)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setRoomWeight==
+
==setExitWeight==
;setRoomWeight(roomID, weight)
+
;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.
  
: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.
+
;Parameters
 +
* ''roomID:''
 +
: Room ID to to set the weight in.
 +
* ''exitCommand:''
 +
: 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.
 +
* ''weight:''
 +
: 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.
  
{{note}} The minimum allowed room weight is 1.
+
: See also: [[#getExitWeights|getExitWeights()]]
  
:To completely avoid a room, make use of [[#lockRoom|lockRoom()]].
+
==setGridMode==
 +
;setGridMode(areaID, true/false)
  
: See also: [[#getRoomWeight|getRoomWeight()]]
+
: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">
setRoomWeight(1532, 3) -- avoid using this room if possible, but don't completely ignore it
+
setGridMode(55, true) -- set area with ID 55 to be in grid mode
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==speedwalk==
+
==setMapUserData==
;speedwalk(dirString, backwards, delay, show)
+
;setMapUserData(key (as a string), value (as a string))
  
: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 mud allows you to walk. It can also be called with a switch to make the function reverse the whole path and lead you backwards.
+
: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.  
  
:Call the function by doing: <code>speedwalk("YourDirectionsString", true/false, delaytime, true/false)</code>
+
:Returns true if successfully set.
 +
: See also: [[#clearMapUserData|clearMapUserData()]], [[#clearMapUserDataItem|clearMapUserDataItem()]], [[#getAllMapUserData|getAllMapUserData()]], [[#getMapUserData|getMapUserData()]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- store general meta information about the map...
 +
setMapUserData("game_name", "Achaea Mudlet map")
 +
 
 +
-- or who the author was
 +
setMapUserData("author", "Bob")
 +
 
 +
-- 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>
 +
 
 +
==setMapZoom==
 +
;setMapZoom(zoom[, areaID])
 +
 
 +
: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.
 +
 
 +
:See also: [[Manual:Mapper_Functions#getMapZoom|getMapZoom()]].
 +
 
 +
;Parameters
 +
* ''zoom:''
 +
: floating point number that is at least 3.0 to set the zoom to.
  
: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.)
+
* ''areaID:''
 +
:(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).
  
: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.)
+
;Returns (only since '''Mudlet ''4.17.0''''')
 +
* ''true'' on success
 +
* ''nil'' and an error message on failure.
  
: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.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
setMapZoom(10.0) -- zoom to a somewhat acceptable level, a bit big but easily visible connections
 +
true
  
:If your Mud 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. (See the link at the beginning of my post for something like that.)
+
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.
 +
 
 +
==setRoomArea==
 +
;setRoomArea(roomID, newAreaID or newAreaName)
 +
 
 +
: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.
 +
 
 +
: See also: [[#resetRoomArea|resetRoomArea()]]
 +
 
 +
==setRoomChar==
 +
;setRoomChar(roomID, character)
 +
 
 +
: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.
 +
 
 +
;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.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
setRoomChar(431, "#")
 +
 
 +
setRoomChar(123, "$")
 +
 
 +
-- emoji's work fine too, and if you'd like it coloured, set the font to Nojo Emoji in settings
 +
setRoomChar(666, "👿")
 +
 
 +
-- clear a symbol with a space
 +
setRoomChar(123, " ")
 +
</syntaxhighlight>
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Historical version information</div>
 +
<div class="mw-collapsible-content">
 +
:Since Mudlet version 3.8 this feature has been extended:
 +
:* 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.
 +
:* 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.
 +
</div></div></div>
 +
 
 +
 
 +
: See also: [[#getRoomChar|getRoomChar()]]
 +
 
 +
==setRoomCharColor==
 +
;setRoomCharColor(roomId, r, g, b)
 +
 
 +
;Parameters
 +
* ''roomID:''
 +
: Room ID to to set char color to.
 +
* ''r:''
 +
: Red component of room char color (0-255)
 +
* ''g:''
 +
: Green component of room char color (0-255)
 +
* ''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
 +
<syntaxhighlight lang="lua">
 +
setRoomEnv(551, 34) -- set room with the ID of 551 to the environment ID 34
 +
</syntaxhighlight>
 +
 
 +
==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==
 +
;setRoomName(roomID, newName)
 +
 
 +
:Renames an existing room to a new name.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
setRoomName(534, "That evil room I shouldn't visit again.")
 +
lockRoom(534, true) -- and lock it just to be safe
 +
</syntaxhighlight>
 +
 
 +
==setRoomUserData==
 +
;setRoomUserData(roomID, key (as a string), value (as a string))
 +
 
 +
: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.
 +
 
 +
:Returns true if successfully set.
 +
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]]
 +
 
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- can use it to store room descriptions...
 +
setRoomUserData(341, "description", "This is a plain-looking room.")
 +
 
 +
-- or whenever it's outdoors or not...
 +
setRoomUserData(341, "outdoors", "true")
 +
 
 +
-- 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.
 +
 
 +
: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
 +
<syntaxhighlight lang="lua">
 +
speedwalk("16d1se1u")
 +
-- Will walk 16 times down, once southeast, once up. All in immediate succession.
 +
 
 +
speedwalk("2ne,3e,2n,e")
 +
-- Will walk twice northeast, thrice east, twice north, once east. All in immediate succession.
 +
 
 +
speedwalk("IN N 3W 2U W", false, 0.5)
 +
-- Will walk in, north, thrice west, twice up, west, with half a second delay between every move.
 +
 
 +
speedwalk("5sw - 3s - 2n - w", true)
 +
-- 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>
 +
 
 +
{{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>
 +
And have ''^//(.+)$'' execute: <code>speedwalk(matches[2], true, 0.7)</code>
 +
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+
 +
 
 +
==stopSpeedwalk==
 +
;stopSpeedwalk()
 +
 
 +
:Stops a speedwalk started using [[#speedwalk|speedwalk()]]
 +
: See also: [[#pauseSpeedwalk|pauseSpeedwalk()]], [[#resumeSpeedwalk|resumeSpeedwalk()]], [[#speedwalk|speedwalk()]]
 +
 
 +
{{MudletVersion|4.13}}
 +
 
 +
<syntaxhighlight lang="lua">
 +
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==
 +
;unHighlightRoom(roomID)
 +
 
 +
:Unhighlights a room if it was previously highlighted and restores the rooms original environment color.
 +
: See also: [[#highlightRoom|highlightRoom()]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
unHighlightRoom(4534)
 +
</syntaxhighlight>
 +
 
 +
==unsetRoomCharColor==
 +
;unsetRoomCharColor(roomId)
 +
 
 +
;Parameters
 +
* ''roomID:''
 +
: Room ID to to unset char color to.
  
:Likewise, if your Mud has any other directions than n, ne, e, se, s, sw, w, nw, u, d, in, out, the function must be adapted to that.
+
Removes char color setting from room, back to automatic determination based on room background lightness.
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
speedwalk("16d1se1u")
+
unsetRoomCharColor(2031)
-- Will walk 16 times down, once southeast, once up. All in immediate succession.
 
 
 
speedwalk("2ne,3e,2n,e")
 
-- Will walk twice northeast, thrice east, twice north, once east. All in immediate succession.
 
 
 
speedwalk("IN N 3W 2U W", false, 0.5)
 
-- Will walk in, north, thrice west, twice up, west, with half a second delay between every move.
 
 
 
speedwalk("5sw - 3s - 2n - w", true)
 
-- 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>
+
{{MudletVersion|4.11}}
And have ''^//(.+)$'' execute: <code>speedwalk(matches[2], true, 0.7)</code>
 
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 will be available in Mudlet versions after 3.12.
 
 
 
==unHighlightRoom==
 
;unHighlightRoom(roomID)
 
 
 
:Unhighlights a room if it was previously highlighted and restores the rooms original environment color.
 
: See also: [[#highlightRoom|highlightRoom()]]
 
 
 
{{note}} Available since Mudlet 2.0 final release
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
unHighlightRoom(4534)
 
</syntaxhighlight>
 
  
 
==updateMap==
 
==updateMap==

Latest revision as of 14:55, 3 November 2024

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 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:

mudlet = mudlet or {}; mudlet.mapper_script = true

addAreaName

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.
See also: deleteArea(), addRoom()
Example
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

addCustomLine

addCustomLine(roomID, id_to, direction, style, color, arrow)
See also: getCustomLines(), removeCustomLine()
Adds a new/replaces an existing custom exit line to the 2D mapper for the room with the Id given.
Parameters
  • roomID:
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.
how these look can be seen in the Map Legend section of the manual
  • 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.
Mudlet VersionAvailable in Mudlet3.0+
Examples
-- create a line from roomid 1 to roomid 2
addCustomLine(1, 2, "N", "dot line", {0, 255, 255}, true)

addCustomLine(1, {{1, 2, 0}, {1, 4, 0}, {0, 5, 0}}, "N", "dash dot dot line", {128, 128, 0}, false)

The second custom exit will look like the below screenshot.

A bigger example that'll create a new area and the room in it:

local areaid = addAreaName("Custom Exit Playground")
local firstRoom = createRoomID()
addRoom(firstRoom, areaid)
setRoomCoordinates(firstRoom, 0, 0, 0)

local secondRoom = createRoomID()
addRoom(secondRoom, areaid)
setRoomCoordinates(secondRoom, 0, 5, 0)

-- make a special exit for this room, and a custom exit line
addSpecialExit(firstRoom, secondRoom, "climb Rope")
addCustomLine(firstRoom, {{1, 2, 0}, {1, 4, 0}, {0, 5, 0}}, "climb Rope", "dash dot dot line", {128, 128, 0}, false)

centerview(firstRoom)

This should result in a map with a custom exit looking something like the following.

Custom exits.png

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(), removeMapEvent(), getMapEvents()
Example
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")

The last line will make a label "Special Room!" under the "Favorites" menu that upon clicking will raise an event with all the arguments.

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)
  local selectedRooms = getMapSelection()["rooms"]
  for i, val in ipairs(selectedRooms) do
    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")

This create menu and two submenu options: "Mark selected rooms as Death Trap" and "Mark selected rooms as single-pass"

addMapMenu

addMapMenu(uniquename, parent, display name)
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().
See also: addMapEvent(), removeMapEvent(), getMapEvents()
Example
-- This will create a menu named: Favorites.
addMapMenu("Favorites")

-- This will create a submenu with the unique id 'Favorites123' under 'Favorites' with the display name of 'More Favorites'.
addMapMenu("Favorites1234343", "Favorites", "More Favorites")

addRoom

addRoom(roomID)
Creates a new room with the given ID, returns true if the room was successfully created.

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

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

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(), removeSpecialExit(), setExit()
Example
-- add a one-way special exit going from room 1 to room 2 using the 'pull rope' command
addSpecialExit(1, 2, "pull rope")

Example in an alias:

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

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(), removeMapEvent(), 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(), 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(), getAllAreaUserData(), clearAreaUserDataItem(), clearRoomUserData()
Example
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
Mudlet VersionAvailable in Mudlet3.0+

clearAreaUserDataItem

clearAreaUserDataItem(areaID, key)
Removes the specific key and value from the user data from a given area.
See also: setAreaUserData(), clearAreaUserData(), clearRoomUserDataItem()
Mudlet VersionAvailable in Mudlet3.0+
Example
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

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

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(), clearRoomUserData(), clearAreaUserData()
Mudlet VersionAvailable in Mudlet3.0+
Example
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

clearMapUserDataItem

clearMapUserDataItem(mapID, key)
Removes the specific key and value from the user data from the map user data.
See also: setMapUserData(), clearMapUserData(), clearAreaRoomUserData()
Example
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
Mudlet VersionAvailable in Mudlet3.0+

clearRoomUserData

clearRoomUserData(roomID)
Clears all user data from a given room.
See also: setRoomUserData(), clearRoomUserDataItem()

Note 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
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

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(), clearRoomUserData(), clearAreaUserDataItem()
Example
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
Mudlet VersionAvailable in Mudlet3.0+

clearSpecialExits

clearSpecialExits(roomID)
Removes all special exits from a room.
See also: addSpecialExit(), removeSpecialExit()
Example
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

closeMapWidget

closeMapWidget()
closes (hides) the map window (similar to clicking on the map icon)
Mudlet VersionAvailable in Mudlet4.7+
See also: openMapWidget(), moveMapWidget(), 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() for the same effect.
Parameters
  • fromID:
Room ID to set the exit stub in.
  • 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(), getExitStubs()
Example
-- 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

createMapLabel

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

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

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

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

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

createMapImageLabel

labelID = createMapImageLabel(areaID, filePath, posx, posy, posz, width, height, zoom, showOnTop[, temporary])
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.
The coordinates 0,0 are in the middle of the map, and are in sync with the room coordinates - so using the x,y values of getRoomCoordinates() will place the label near that room.
See also: createMapLabel, deleteMapLabel
Example
-- 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)

createMapper

createMapper([name of userwindow], x, y, width, height)
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.

Note Note: name of userwindow available in Mudlet 4.6.1+

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

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

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
  • minimumStartingRoomId (optional, available in Mudlet 3.0+):
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.
See also: addRoom()

deleteArea

deleteArea(areaID or areaName)
Deletes the given area and all rooms in it. Returns true on success or nil + error message otherwise.
See also: addAreaName()
Parameters
  • areaID:
Area ID to delete, or:
  • areaName (available in Mudlet 3.0+):
Area name to delete.


Example
-- delete by areaID
deleteArea(23)
-- or since Mudlet 3.0, by area name
deleteArea("Big city")

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()
Mudlet VersionAvailable in Mudlet4.14.0+
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."

Note Note: Prior to the introduction of this function, the recommended method to achieve the same result was to use 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
deleteMap()

deleteMapLabel

deleteMapLabel(areaID, labelID)
Deletes a map label from a specific area.
See also: createMapLabel()
Example
deleteMapLabel(50, 1)

deleteRoom

deleteRoom(roomID)
Deletes an individual room, and unlinks all exits leading to and from it.
Example
deleteRoom(335)

disableMapInfo

disableMapInfo(label)

Disable the particular map info - same as toggling off checkbox from select box under mapper.

Parameters
  • label:
Name under which map info to be disabled was registered.
See also: registerMapInfo(), enableMapInfo(), killMapInfo()
Mudlet VersionAvailable in Mudlet4.11+

enableMapInfo

enableMapInfo(label)

Enable the particular map info - same as toggling on checkbox from select box under mapper.

Parameters
  • label:
Name under which map info to be enabled was registered.
See also: registerMapInfo(), disableMapInfo(), killMapInfo()
Mudlet VersionAvailable in Mudlet4.11+

getAllAreaUserData

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: clearAreaUserData(), clearAreaUserDataItem(), searchAreaUserData(), setAreaUserData()
Example
display(getAllAreaUserData(34))
--might result in:--
{
  country = "Andor",
  ruler = "Queen Morgase Trakand"
}
Mudlet VersionAvailable in Mudlet3.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()
Example
display(getAllMapUserData())
--might result in:--
{
  description = [[This map is about so and so game]],
  author = "Bob",
  ["last updated"] = "December 5, 2020"
}
Mudlet VersionAvailable in Mudlet3.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(), but this function has the ability to pick up one-way exits coming into the room as well.
Mudlet VersionAvailable in Mudlet3.0+
Example
-- print the list of rooms that have exits leading into room 512
for _, roomid in ipairs(getAllRoomEntrances(512)) do 
  print(roomid)
end
See also: 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() - for a related command that only returns the data keys.
Mudlet VersionAvailable in Mudlet3.0+
Example
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"
}

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(), getRoomExits()
Parameters
  • areaID:
Area ID to list the exits for.
  • showExits:
Boolean argument, if true then the exits that lead out to another area will be listed for each room.


Example
-- list all border rooms for area 44:
getAreaExits(44)

-- returns:
--[[
{
  7091,
  10659,
  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
  }
}
]]

getAreaRooms

getAreaRooms(area id)
Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or nil if no such area exists. Indexing starts at 0.
Example
-- 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
      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

getAreaTable

areaTable = getAreaTable()
Returns a key(area name)-value(area id) table with all known areas and their IDs.
Historical Version Note

Note 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()
Example
-- example function that returns the area ID for a given area

function findAreaID(areaname)
  local list = getAreaTable()

  -- iterate over the list of areas, matching them with substring match. 
  -- if we get match a single area, then return it's ID, otherwise return
  -- 'false' and a message that there are than one are matches
  local returnid, fullareaname
  for area, id in pairs(list) do
    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

getAreaTableSwap

areaTable = getAreaTableSwap()
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.
Historical Version Note

Note 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() function for storing the user data.
See also
clearAreaUserData(), clearAreaUserDataItem(), getAllAreaUserData(), searchAreaUserData(), setAreaUserData()
Example
display(getAreaUserData(34, "country"))
-- might produce --
"Andor"

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()
Example
{
  envid1 = {r, g, b, alpha},
  envid2 = {r, g, b, alpha}
}

getCustomLines

lineTable = getCustomLines(roomID)
See also: addCustomLine(), 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.
Mudlet VersionAvailable in Mudlet3.0.+
Example
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
      }
    }
  }
}

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: addCustomLine(), removeCustomLine(), getCustomLines()
Mudlet VersionAvailable in Mudlet 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
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 } }
  }
}

getDoors

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.
Parameters
  • roomID:
Room ID to check for doors in.
See also: setDoor()
Example
-- 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

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. Returns nil plus error message of called on a non-existent room.

The directions numbers can be deciphered using this table;

  local stubmap = {
      [1] = "north",  [2] = "northeast",  [3] = "northwest",  [4] = "east",
      [5] = "west",   [6] = "south",      [7] = "southeast",  [8] = "southwest",
      [9] = "up",     [10] = "down",      [11] = "in",        [12] = "out",
      [13] = "northup", [14] = "southdown", [15] = "southup", [16] = "northdown",
      [17] = "eastup", [18] = "westdown", [19] = "westup",    [20] = "eastdown"
  }
See also: setExitStub(), connectExitStub(), getExitStubs1()
Example
-- show the exit stubs in room 6 as numbers
local stubs = getExitStubs(6)
for i = 0, #stubs do print(stubs[i]) end
Historical Version Note

Note 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.
See also
getExitStubs()
Example
-- show the exit stubs in room 6 as numbers
for k,v in ipairs(getExitStubs1(6)) do print(k,v) end

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

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.
Mudlet VersionAvailable in Mudlet3.11+
Parameters
  • areaID:
Area ID (number) to view the grid mode of.
See also: setGridMode()
Example
getGridMode(55)
-- will return: false
setGridMode(55, true) -- set area with ID 55 to be in grid mode
getGridMode(55)
-- will return: true

getMapEvents

mapevents = getMapEvents()
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().
See also: addMapMenu(), removeMapEvent(), addMapEvent()
Example
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
Mudlet VersionAvailable in Mudlet3.3+

getMapLabel

labelinfo = getMapLabel(areaID, labelID or labelText)
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.
BgColor and FgColor are tables with r,g,b keys, each holding 0-255 color component value.
Pixmap is base64 encoded image of label.

Note 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(), getMapLabels()

Example
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)
}

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() it.
If there are no labels in the area at all, it will return an empty table.
See also: createMapLabel(), getMapLabel(), deleteMapLabel()
Example
display(getMapLabels(43))
table {
  0: ''
  1: 'Waterways'
}

deleteMapLabel(43, 0)
display(getMapLabels(43))
table {
  1: 'Waterways'
}

getMapMenus

getMapMenus()
Returns a table with the available map menus as key-value in the format of map menu - parent item. If an item is positioned at the menu's top-level, the value will say top-level.
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 {} is returned.
See also: addMapMenu(), addMapEvent()
Example
-- given the following menu structure:
top-level
  menu1
    menu1.1
      action1.1.1
    menu1.2
      action1.2.1
  menu2

getMapMenus() -- will return:
{
  menu2 = "top-level",
  menu1.2 = "menu1",
  menu1.1 = "menu1",
  menu1 = "top-level"
}

getMapSelection

getMapSelection()
Returns a table containing details of the current mouse selection in the 2D mapper.
Reports on one or more rooms being selected (i.e. they are highlighted in orange).
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.
Example - several rooms selected
display(getMapSelection())
{
  center = 5013,
  rooms = {
    5011,
    5012,
    5013,
    5014,
    5018,
    5019,
    5020
  }
}
Example - one room selected
display(getMapSelection())
{
  center = 5013,
  rooms = {
    5013
  }
}
Example - no or something other than a room selected
display(getMapSelection())
{
}
Mudlet VersionAvailable in Mudlet3.17+

getMapUserData

getMapUserData( key )
Parameters
  • key:
string used as a key to select the data stored in the map as a whole.
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.
See also: getAllMapUserData(), setMapUserData()
Example
display(getMapUserData("last updated"))
--might result in:--
"December 5, 2020"
Mudlet VersionAvailable in Mudlet3.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: setMapZoom().
Mudlet VersionAvailable in Mudlet 4.17.0+
Parameters
  • 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
  • A floating point number on success
  • nil and an error message on failure.
Example
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

Note 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: translateTable()
Example
-- check if we can go to room 155 from room 34 - if yes, go to it
if getPath(34,155) then
  gotoRoom(155)
else
  echo("\nCan't go there!")
end

getPlayerRoom

getPlayerRoom()
Returns the current player location as set by centerview().
See also: centerview
Example
display("We're currently in " .. getRoomName(getPlayerRoom()))
Mudlet VersionAvailable in Mudlet3.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() function, or use the getRoomAreaName() function.

Note Note: If the room ID does not exist, this function will raise an error.

Example
display("Area ID of room #100 is: "..getRoomArea(100))

display("Area name for room #100 is: "..getRoomAreaName(getRoomArea(100)))

getRoomAreaName

getRoomAreaName(areaID or areaName)
Returns the area name for a given area id; or the area id for a given area name.

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

Example
echo(string.format("room id #455 is in %s.", getRoomAreaName(getRoomArea(455))))


getRoomChar

getRoomChar(roomID)
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() or with the symbol (was letter in prior versions) context menu item for rooms in the 2D Map.

getRoomCharColor

r,g,b = getRoomCharColor(roomID)
Returns the color of the Room Character as a set of r,g,b color coordinates.
See also
setRoomCharColor(), getRoomChar()
Parameters
  • roomID:
The room ID to get the room character color from
Returns
  • The color as 3 separate numbers, red, green, and blue from 0-255
Example
-- gets the color of the room character set on room 12345. If no room character is set the default 'color' is 0,0,0
local r,g,b = getRoomCharColor(12345)
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>.\")

getRoomCoordinates

x,y,z = getRoomCoordinates(roomID)
Returns the room coordinates of the given room ID.
See also
setRoomCoordinates()
Example
local x,y,z = getRoomCoordinates(roomID)
echo("Room Coordinates for "..roomID..":")
echo("\n     X:"..x)
echo("\n     Y:"..y)
echo("\n     Z:"..z)
-- 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
  return t
end

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
function checkID(id)
  echo(string.format("The env ID of room #%d is %d.\n", id, getRoomEnv(id)))
end

getRoomExits

getRoomExits (roomID)
Returns the currently known non-special exits for a room in an key-index form: exit = exitroomid.
See also: getSpecialExits()
Example
{
  south = 143,
  west = 432
}

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

local exits = getRoomExits(mycurrentroomid)
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

getRoomHashByID

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.
See also: getRoomIDbyHash()
Mudlet VersionAvailable in Mudlet3.13.0+
Example
    for id,name in pairs(getRooms()) do
        local h = getRoomUserData(id, "herbs")
        if h ~= "" then
            echo(string.format([[["%s"] = "%s",]], getRoomHashByID(id), h))
            echo("\n")
        end
    end

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 Avalon.de). -1 is returned if no room ID matches the hash.
See also: getRoomHashByID()
Example
-- 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

getRoomName

getRoomName(roomID)
Returns the room name for a given room id.
Example
echo(string.format("The name of the room id #455 is %s.", getRoomName(455))

getRooms

rooms = getRooms()
Returns the list of all rooms in the map in the whole map in roomid - room name format.
Example
-- 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

getRoomsByPosition

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.

Note 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 table.size() instead.

Example
-- sample alias to determine a room nearby, given a relative direction from the current room

local otherroom
if matches[2] == "" then
  local w = matches[3]
  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
    mmp.echo("The room "..w.." of us has an ID of "..otherroom)
  end

getRoomUserData

getRoomUserData(roomID, key)
Returns the user data value (string) stored at a given room with a given key (string), or "" if none is stored. Use setRoomUserData() function for setting the user data.
Example
display(getRoomUserData(341, "visitcount"))
getRoomUserData(roomID, key, enableFullErrorReporting)
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.
See also: clearRoomUserData(), clearRoomUserDataItem(), getAllRoomUserData(), getRoomUserDataKeys(), searchRoomUserData(), setRoomUserData()
Example
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

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(), clearRoomUserDataItem(), getAllRoomUserData(), getRoomUserData(), searchRoomUserData(), setRoomUserData()
Example
display(getRoomUserDataKeys(3441))
--might result in:--
{
  "description",
  "doorname_up",
}
Mudlet VersionAvailable in Mudlet3.0+

getRoomWeight

getRoomWeight(roomID)
Returns the weight of a room. By default, all new rooms have a weight of 1.
See also: setRoomWeight()
Example
display("Original weight of room 541: "..getRoomWeight(541))
setRoomWeight(541, 3)
display("New weight of room 541: "..getRoomWeight(541))

getSpecialExits

exits = getSpecialExits(roomID[, listAllExits])
Parameters
  • roomID:
Room ID to return the special exits of.
  • listAllExits:
In the case where there is more than one special exit to the same room ID list all of them.
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
Historical Version Note
(Since TBA) In the case where there is more than one special exit to the same room ID list all of them.
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.
See also: getRoomExits()
Example
-- There are three special exits from 1337 to the room 42:
-- "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"}
}

getSpecialExitsSwap

getSpecialExitsSwap(roomID)
Very similar to 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, 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
-- check if the east exit of room 1201 is locked
display(hasExitLock(1201, 4))
display(hasExitLock(1201, "e"))
display(hasExitLock(1201, "east"))
See also: lockExit()

hasSpecialExitLock

hasSpecialExitLock(from roomID, to roomID, moveCommand)
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.

See also: lockSpecialExit()

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

highlightRoom

highlightRoom( roomID, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)
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.
Parameters
  • roomID
ID of the room to be colored.
  • color1Red, color1Green, color1Blue
RGB values of the first color.
  • color2Red, color2Green, color2Blue
RGB values of the second color.
  • 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()
-- simple example:
highlightRoom(351, 255,0,0, 0,0,255, 1, 255, 255)

-- another example, 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)

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(), enableMapInfo(), disableMapInfo()
Mudlet VersionAvailable in Mudlet4.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()

Returns:

  • true on success
  • nil and an error message on failure.
Example
loadJsonMap(getMudletHomeDir() .. "/map.json")

true
Mudlet VersionAvailable in Mudlet4.11.0+

loadMap

loadMap(file location)
Loads the map file from a given location. The map file must be in Mudlet's format - saved with 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 a boolean for whenever the loading succeeded. Note that the mapper must be open, or this will fail.
Using no arguments will load the last saved map.
  loadMap("/home/user/Desktop/Mudlet Map.dat")

Note Note: A file name ending with .xml 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. Direction can be specified as a number, short direction name ("nw") or long direction name ("northwest").
See also: hasExitLock()
Example
-- lock the east exit of room 1201 so we never path through it
lockExit(1201, 4, true)

lockRoom

lockRoom (roomID, lockIfTrue)
Locks a given room id from future speed walks (thus the mapper will never path through that room).
See also: roomLocked()
Example
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.

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(), lockExit(), lockRoom()
Example
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

moveMapWidget

moveMapWidget(Xpos, Ypos)
moves the map window to the given position.
See also: openMapWidget(), closeMapWidget(), 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.
Mudlet VersionAvailable in Mudlet4.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(), moveMapWidget(), resizeMapWidget()
Mudlet VersionAvailable in Mudlet4.7+
Parameters

Note 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 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()
See also: speedwalk(), stopSpeedwalk(), resumeSpeedwalk()
Mudlet VersionAvailable in Mudlet4.13+
local ok, err = pauseSpeedwalk()
if not ok then
  debugc(f"Error: unable to pause speedwalk because {err}\n")
  return
end

registerMapInfo

registerMapInfo(label, function)

Adds an extra 'map info' to the mapper widget which can be used to display custom information.

See also: killMapInfo(), enableMapInfo(), disableMapInfo()
Mudlet VersionAvailable in Mudlet4.11+

Note Note: You can register multiple map infos - just give them unique names and toggle whichever ones you need.

Parameters
  • 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() again.
  • function:
Callback function that will be responsible for returning information how to draw map info fragment.

Callback function is called with following arguments:

  • 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:

  • 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")
  • isBold (optional) - true/false - determines whether text will be bold
  • 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 Note: Map info is registered in disabled state, you need to enable it through script or by selecting checkbox under mapper.

registerMapInfo("My very own handler!", function(roomId, selectionSize, areaId, displayedArea) 
  return string.format("RoomId: %d\nNumbers of room selected: %d\nAreaId: %d\nDisplaying area: %d", roomId, selectionSize, areaId, displayedArea),
  true, true, 0, 255, 0
end)
enableMapInfo("My very own handler!")

Example will display something like that:

Map-info-example.png

Using function arguments is completely optional and you can determine whether and how to display map info completely externally.

registerMapInfo("Alert", function() 
  if character.hp < 20 then
    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
  else
    return "" -- will not return anything
  end
end)
enableMapInfo("Alert")

resumeSpeedwalk

resumeSpeedwalk()
Continues a speedwalk paused using pauseSpeedwalk()
See also: speedwalk(), pauseSpeedwalk(), stopSpeedwalk()
Mudlet VersionAvailable in Mudlet4.13+
local ok, err = resumeSpeedwalk()
if not ok then
  cecho(f"\n<red>Error:<reset> Problem resuming speedwalk: {err}\n")
  return
end
cecho("\n<green>Successfully resumed speedwalk!\n")

removeCustomLine

removeCustomLine(roomID, direction)
Removes the custom exit line that's associated with a specific exit of a room.
See also: addCustomLine(), getCustomLines()
Example
-- remove custom exit line that starts in room 315 going north
removeCustomLine(315, "n")

removeMapEvent

removeMapEvent(event name)
Removes the given menu entry from a mappers right-click menu. You can add custom ones with addMapEvent().
See also: addMapEvent(), getMapEvents(), removeMapMenu()
Example
addMapEvent("room a", "onFavorite") -- add one to the general menu
removeMapEvent("room a") -- removes the said menu

removeMapMenu

removeMapMenu(menu name)
Removes the given submenu from a mappers right-click menu. You can add custom ones with addMapMenu().
See also: addMapMenu(), getMapMenus(), removeMapEvent()
Example
addMapMenu("Test") -- add submenu to the general menu
removeMapMenu("Test") -- removes that same menu again

removeSpecialExit

removeSpecialExit(roomID, command)
Removes the special exit which is accessed by command from the room with the given roomID.
See also: addSpecialExit(), clearSpecialExits()
Example
addSpecialExit(1, 2, "pull rope") -- add a special exit from room 1 to room 2
removeSpecialExit(1, "pull rope") -- removes the exit again

resetRoomArea

resetRoomArea (roomID)
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(), getRoomArea()
Example
resetRoomArea(3143)

resizeMapWidget

resizeMapWidget(width, height)
resizes a map window with given width, height.
See also: openMapWidget(), closeMapWidget(), moveMapWidget()
Mudlet VersionAvailable in Mudlet4.7+
Parameters
  • width:
The width of the map window, in pixels. Passed as an integer number.
  • height:
The height of the map window, in pixels. Passed as an integer number.

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()
Example
echo(string.format("Is room #4545 locked? %s.", roomLocked(4545) and "Yep" or "Nope"))

saveJsonMap

saveJsonMap([pathFileName])

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()
Mudlet VersionAvailable in Mudlet4.11.0+
Parameters
  • pathFileName (optional in Mudlet 4.12+): a string that is an absolute path and file name to save the data into.
Returns
  • true on success
  • nil and an error message on failure.
Example
saveJsonMap(getMudletHomeDir() .. "/map.json")

true

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
  • location
(optional) save the map to the given location if provided, or the default one otherwise.
  • version
(optional) map version as a number to use when saving (Mudlet 3.17+)
See also: loadMap()
Example
local savedok = saveMap(getMudletHomeDir().."/my fancy map.dat")
if not savedok then
  echo("Couldn't save :(\n")
else
  echo("Saved fine!\n")
end

-- save with a particular map version
saveMap(20)

searchAreaUserData

searchAreaUserData(area number | area name[, case-sensitive [, exact-match]])
Searches Areas' User Data in a manner exactly the same as 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

searchRoom (room number | room name[, case-sensitive [, exact-match]])
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.
If you pass it a number instead of a string as just one argument, it'll act like getRoomName() and return the room name.
Examples
-- 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"
}

Note 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

searchRoomUserData([key, [value]])
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(), clearRoomUserDataItem(), getAllRoomUserData(), getRoomUserData(), getRoomUserDataKeys(), setRoomUserData()
searchRoomUserData(key, value)
Reports a (sorted) list of all room ids with user data with the given "value" for the given (case sensitive) "key".
searchRoomUserData(key)
Reports a (sorted) list of the unique values from all rooms with user data with the given (case sensitive) "key".
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.
Mudlet VersionAvailable in Mudlet3.0+
Examples
-- 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
}
]]

setAreaName

setAreaName(areaID or areaName, newName)
Names, or renames an existing area to the new name. The area must be created first with addAreaName() and it must be unique.

Note Note: parameter areaName is available since Mudlet 3.0.

See also: deleteArea(), addAreaName()
Example
setAreaName(2, "My city")

-- available since Mudlet 3.0
setAreaName("My old city name", "My new city name")

setAreaUserData

setAreaUserData(areaID, key (as a string), value (as a string))
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.
Returns true if successfully set.
See also: clearAreaUserData(), clearAreaUserDataItem(), getAllAreaUserData(), getAreaUserData(), searchAreaUserData()
Mudlet VersionAvailable in Mudlet3.0+
Example
-- can use it to store extra area details...
setAreaUserData(34, "country", "Andor.")

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

setCustomEnvColor

setCustomEnvColor(environmentID, r,g,b,a)
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.
See also: getCustomEnvColorTable(), setRoomEnv()

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

Default colour table for Mudlet mapper.
Example
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

setDoor

setDoor(roomID, exitCommand, doorStatus)
Creates or deletes a door in a room. Doors are purely visual - they don't affect default pathfinding (use a custom script to overcome this). 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()
Parameters
  • roomID:
Room ID to to create the door in.
  • exitCommand:
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.
  • doorStatus:
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
-- make a door on the east exit of room 4234 that is currently open
setDoor(4234, 'e', 1)

-- remove a door from room 923 that points north
setDoor(923, 'n', 0)

setExit

setExit(from roomID, to roomID, direction)
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.
Returns false if the exit creation didn't work.
See also: addSpecialExit()
Example
-- 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

This function can also delete exits from a room if you use it like so:

setExit(from roomID, -1, direction)

- which will delete an outgoing exit in the specified direction from a room.

setExitStub

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.

Parameters
  • roomID:
The room to place an exit stub in, as a number.
  • 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(), connectExitStub()
Example

Create an exit stub to the south from room 8:

setExitStub(8, "s", true)

How to delete all exit stubs in a room:

for i,v in pairs(getExitStubs(roomID)) do
  setExitStub(roomID, v,false)
end

setExitWeight

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.
Parameters
  • roomID:
Room ID to to set the weight in.
  • exitCommand:
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.
  • weight:
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.
See also: getExitWeights()

setGridMode

setGridMode(areaID, true/false)
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.
regular mode
grid mode
See also: getGridMode()
Example
setGridMode(55, true) -- set area with ID 55 to be in grid mode

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.
See also: clearMapUserData(), clearMapUserDataItem(), getAllMapUserData(), getMapUserData()
Example
-- store general meta information about the map...
setMapUserData("game_name", "Achaea Mudlet map")

-- or who the author was
setMapUserData("author", "Bob")

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

setMapZoom

setMapZoom(zoom[, areaID])
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.
See also: getMapZoom().
Parameters
  • zoom:
floating point number that is at least 3.0 to set the zoom to.
  • areaID:
(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
setMapZoom(10.0) -- zoom to a somewhat acceptable level, a bit big but easily visible connections
true

setMapZoom(2.5 + getMapZoom(1), 1) -- zoom out the area with ID 1 by 2.5
true

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

setRoomArea

setRoomArea(roomID, newAreaID or newAreaName)
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.
See also: resetRoomArea()

setRoomChar

setRoomChar(roomID, character)
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.
Game-related symbols for your map
Example
setRoomChar(431, "#")

setRoomChar(123, "$")

-- emoji's work fine too, and if you'd like it coloured, set the font to Nojo Emoji in settings
setRoomChar(666, "👿")

-- clear a symbol with a space
setRoomChar(123, " ")
Historical version information
Since Mudlet version 3.8 this feature has been extended:
  • 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.
  • 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()

setRoomCharColor

setRoomCharColor(roomId, r, g, b)
Parameters
  • roomID:
Room ID to to set char color to.
  • r:
Red component of room char color (0-255)
  • g:
Green component of room char color (0-255)
  • b:
Blue component of room char color (0-255)

Sets color for room symbol.

setRoomCharColor(2402, 255, 0, 0)
setRoomCharColor(2403, 0, 255, 0)
setRoomCharColor(2404, 0, 0, 255)
Mudlet VersionAvailable in Mudlet4.11+
See also: 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 Note: 0,0,0 is the center of the map.

Examples
-- alias pattern: ^set rc (-?\d+) (-?\d+) (-?\d+)$
-- this sets the current room to the supplied coordinates
setRoomCoordinates(roomID,x,y,z)
centerview(roomID)
You can make them relative asa well:
-- 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)

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()
Example
setRoomEnv(551, 34) -- set room with the ID of 551 to the environment ID 34

setRoomIDbyHash

setRoomIDbyHash(roomID, hash)
Sets the hash to be associated with the given roomID. See also getRoomIDbyHash().
If the room was associated with a different hash, or vice versa, that association will be superseded.

setRoomName

setRoomName(roomID, newName)
Renames an existing room to a new name.
Example
setRoomName(534, "That evil room I shouldn't visit again.")
lockRoom(534, true) -- and lock it just to be safe

setRoomUserData

setRoomUserData(roomID, key (as a string), value (as a string))
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.
Returns true if successfully set.
See also: clearRoomUserData(), clearRoomUserDataItem(), getAllRoomUserData(), getRoomUserData(), searchRoomUserData()


Example
-- can use it to store room descriptions...
setRoomUserData(341, "description", "This is a plain-looking room.")

-- or whenever it's outdoors or not...
setRoomUserData(341, "outdoors", "true")

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

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 Note: The minimum allowed room weight is 1.

To completely avoid a room, make use of lockRoom().
See also: getRoomWeight()


Example
setRoomWeight(1532, 3) -- avoid using this room if possible, but don't completely ignore it


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.
Call the function by doing: speedwalk("YourDirectionsString", true/false, delaytime, true/false)
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
speedwalk("16d1se1u")
-- Will walk 16 times down, once southeast, once up. All in immediate succession.

speedwalk("2ne,3e,2n,e")
-- Will walk twice northeast, thrice east, twice north, once east. All in immediate succession.

speedwalk("IN N 3W 2U W", false, 0.5)
-- Will walk in, north, thrice west, twice up, west, with half a second delay between every move.

speedwalk("5sw - 3s - 2n - w", true)
-- 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.

Note Note: The probably most logical usage of this would be to put it in an alias. For example, have the pattern ^/(.+)$ execute: speedwalk(matches[2], false, 0.7) And have ^//(.+)$ execute: speedwalk(matches[2], true, 0.7) Or make aliases like: ^banktohome$ to execute speedwalk("2ne,e,ne,e,3u,in", true, 0.5)

Note Note: The show parameter for this function is available in Mudlet 3.12+

stopSpeedwalk

stopSpeedwalk()
Stops a speedwalk started using speedwalk()
See also: pauseSpeedwalk(), resumeSpeedwalk(), speedwalk()
Mudlet VersionAvailable in Mudlet4.13+
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")

unHighlightRoom

unHighlightRoom(roomID)
Unhighlights a room if it was previously highlighted and restores the rooms original environment color.
See also: highlightRoom()
Example
unHighlightRoom(4534)

unsetRoomCharColor

unsetRoomCharColor(roomId)
Parameters
  • roomID:
Room ID to to unset char color to.

Removes char color setting from room, back to automatic determination based on room background lightness.

unsetRoomCharColor(2031)
Mudlet VersionAvailable in Mudlet4.11+

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()
Example
-- delete a some room
deleteRoom(500)
-- now make the map show that it's gone
updateMap()