Difference between revisions of "User:Molideus"

From Mudlet
Jump to navigation Jump to search
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{TOC right}}
 
{{TOC right}}
{{#description2:Mudlet API documentation for functions to manipulate Mudlet's scripting objects - triggers, aliases, and so forth.}}
+
{{#description2:Mudlet API documentation for functions that manipulate the mapper and its related features.}}
= Mudlet Object Functions =
+
= Mapper Functions =
Collection of functions to manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
+
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.
  
==addCmdLineSuggestion==
+
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:
;addCmdLineSuggestion([name], suggestion)
+
<syntaxhighlight lang="lua">
: Add suggestion for tab completion for specified command line.
+
mudlet = mudlet or {}; mudlet.mapper_script = true
 +
</syntaxhighlight>
 +
 
 +
==addAreaName==
 +
;areaID = addAreaName(areaName)
  
: For example, start typing ''he'' and hit ''TAB'' until ''help'' appears in command line.
+
: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.
: Non-word characters are skipped (this is the reason why they can't be added at start of suggestion), therefore it's also possible to type: ''/he'' and hit ''TAB''.
+
: See also: [[#deleteArea|deleteArea()]], [[#addRoom|addRoom()]]
  
: See also: [[Manual:Lua_Functions#clearCmdLineSuggestions|clearCmdLineSuggestions()]], [[Manual:Lua_Functions#removeCmdLineSuggestion|removeCmdLineSuggestion()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
local newId, err = addAreaName("My House")
  
{{MudletVersion|4.11}}
+
if newId == nil or newId < 1 or err then
 +
  echo("That area name could not be added - error is: ".. err.."\n")
 +
else
 +
  cecho("<green>Created new area with the ID of "..newId..".\n")
 +
end
 +
</syntaxhighlight>
 +
 
 +
==addCustomLine==
 +
;addCustomLine(roomID, id_to, direction, style, color, arrow)
 +
: See also: [[#getCustomLines|getCustomLines()]], [[#removeCustomLine|removeCustomLine()]]
 +
 
 +
:Adds a new/replaces an existing custom exit line to the 2D mapper for the room with the Id given.
  
 
;Parameters
 
;Parameters
* ''name'': optional command line name, if skipped main command line will be used
+
* ''roomID:''
* ''suggestion'' - suggestion as a single word to add to tab completion (only the following are allowed: ''0-9A-Za-z_'')
+
: Room ID to attach the custom line to.
 +
* ''id_to:''
 +
: EITHER: a room Id number, of a room on same area who's x and y coordinates are used as the other end of a SINGLE segment custom line (it does NOT imply that is what the exit it represent goes to, just the location of the end of the line);
 +
: OR: a table of sets of THREE (x,y and z) coordinates in that order, x and y can be decimals, z is an integer ('''and must be present and be the same for all points on the line''', though it is irrelevant to what is produced as the line is drawn on the same z-coordinate as the room that the line is attached to!)
 +
* ''direction:'' a string to associate the line with a valid exit direction, "n", "ne", "e", "se", "s", "sw", "w", "nw", "up", "down", "in" or "out" or a special exit (before Mudlet 3.17 this was case-sensitive and cardinal directions had to be uppercase).
 +
* ''style:'' a string, one of: "solid line", "dot line", "dash line", "dash dot line" or "dash dot dot line" exactly.
 +
* ''color:'' a table of three integers between 0 and 255 as the custom line color as the red, green and blue components in that order.
 +
* ''arrow:'' a boolean which if true will set the custom line to have an arrow on the end of the last segment.
 +
 
 +
{{MudletVersion|3.0}}
  
Example:
+
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
addCmdLineSuggestion("help")
+
-- create a line from roomid 1 to roomid 2
 +
addCustomLine(1, 2, "N", "dot line", {0, 255, 255}, true)
  
local suggestions = {"Pneumonoultramicroscopicsilicovolcanoconiosis", "supercalifragilisticexpialidocious", "serendipitous"}
+
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)
for _, suggestion in ipairs(suggestions) do
 
  addCmdLineSuggestion(suggestion)
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==adjustStopWatch==
+
A bigger example that'll create a new area and the room in it:
;adjustStopWatch(watchID/watchName, amount)
+
 
: Adjusts the elapsed time on the stopwatch forward or backwards by the amount of time. It will work even on stopwatches that are not running, and thus can be used to preset a newly created stopwatch with a negative amount so that it runs down from a negative time towards zero at the preset time.
+
<syntaxhighlight lang="lua">
 +
local areaid = addAreaName("my first area")
 +
local newroomid = createRoomID()
 +
addRoom(newroomid)
 +
setRoomArea(newroomid, "my first area")
 +
setRoomCoordinates(newroomid, 0, 0, 0)
  
;Parameters
+
local otherroomid = createRoomID()
* watchID (number) / watchName (string): The stopwatch ID you get with [[Manual:Lua_Functions#createStopWatch|createStopWatch()]] or the name given to that function or later set with [[Manual:Lua_Functions#setStopWatchName|setStopWatchName()]].
+
addRoom(otherroomid)
* amount (decimal number): An amount in seconds to adjust the stopwatch by, positive amounts increase the recorded elapsed time.
+
setRoomArea(otherroomid, "my first area")
 +
setRoomCoordinates(otherroomid, 0, 5, 0)
 +
 
 +
addSpecialExit(newroomid, otherroomid, "climb Rope")
 +
addCustomLine(newroomid, {{4.5, 5.5, 3}, {4.5, 9.5, 3}, {6.0, 9.5, 3}}, "climb Rope", "dash dot dot line", {128, 128, 0}, false)
 +
 
 +
centerview(newroomid)
 +
</syntaxhighlight>
 +
 
 +
==addMapEvent==
 +
;addMapEvent(uniquename, event name, parent, display name, arguments)
  
;Returns
+
: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.
* true on success if the stopwatch was found and thus adjusted, or nil and an error message if not.
+
: See also: [[#addMapMenu|addMapMenu()]], [[#removeMapEvent|removeMapEvent()]], [[#getMapEvents|getMapEvents()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- demo of a persistent stopWatch used to real time a mission
+
addMapEvent("room a", "onFavorite") -- will make a label "room a" on the map menu's right click that calls onFavorite
-- called with a positive number of seconds it will start a "missionStopWatch"
 
-- unless there already is one in which case it will instead report on
 
-- the deadline. use 'stopStopWatch("missionStopWatch")' when the mission
 
-- is done and 'deleteStopWatch("missionStopWatch")' when the existing mission
 
-- is to be disposed of. Until then repeated use of 'mission(interval)' will
 
-- just give updates...
 
function mission(time)
 
  local missionTimeTable = missionTimeTable or {}
 
  
  if createStopWatch("missionStopWatch") then
+
addMapEvent("room b", "onFavorite", "Favorites", "Special Room!", 12345, "arg1", "arg2", "argn")  
    adjustStopWatch("missionStopWatch", -tonumber(time))
+
</syntaxhighlight>
    setStopWatchPersistence("missionStopWatch", true)
+
The last line will make a label "Special Room!" under the "Favorites" menu that upon clicking will raise an event with all the arguments.
    missionTimeTable = getStopWatchBrokenDownTime("missionStopWatch")
+
 
 +
<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")
  
    echo(string.format("Get cracking, you have %02i:%02i:%02i hg:m:s left.\n", missionTimeTable.hours, missionTimeTable.minutes, missionTimeTable.seconds))
+
function onMapMarkSelectedRooms(event, markRoomType)
    startStopWatch("missionStopWatch")
+
   local selectedRooms = getMapSelection()["rooms"]
   else
+
  for i, val in ipairs(selectedRooms) do
    -- it already exists, so instead report what is/was the time on it
+
    if markRoomType == "markRoomsAsDeathTrap" then
    --[=[ We know that the stop watch exists - we just need to find the ID
+
      local r, g, b = unpack(color_table.black)
      so we can get the running detail which is only available from the getStopWatches()
+
       --death trap
      table and that is indexed by ID]=]
+
      setRoomEnv(val, 300)
    for k,v in pairs(getStopWatches()) do
+
      --death traps Env
      if v.name == "missionStopWatch" then
+
       setCustomEnvColor(300, r, g, b, 255)
        missionTimeTable = v
+
      setRoomChar(val, "☠️")
       end
+
       lockRoom(val, true)
    end
+
    elseif markRoomType == "markRoomsAsOneRoom" then
    if missionTimeTable.isRunning then
+
      local r, g, b = unpack(color_table.LightCoral)
       if missionTimeTable.elapsedTime.negative then
+
       --single-pass
        echo(string.format("Better hurry up, the clock is ticking on an existing mission and you only have %02i:%02i:%02i h:m:s left.\n", missionTimeTable.elapsedTime.hours, missionTimeTable.elapsedTime.minutes, missionTimeTable.elapsedTime.seconds))
+
      setRoomEnv(val, 301)
       else
+
       --one room Env
        echo(string.format("Bad news, you are past the deadline on an existing mission by %02i:%02i:%02i h:m:s !\n", missionTimeTable.elapsedTime.hours, missionTimeTable.elapsedTime.minutes, missionTimeTable.elapsedTime.seconds))
+
      setCustomEnvColor(301, r, g, b, 255)
       end
+
       setRoomChar(val, "🚹")
    else
 
       if missionTimeTable.elapsedTime.negative then
 
        echo(string.format("Well done! You have already completed a mission %02i:%02i:%02i h:m:s before the deadline ...\n", missionTimeTable.elapsedTime.hours, missionTimeTable.elapsedTime.minutes, missionTimeTable.elapsedTime.seconds))
 
       else
 
        echo(string.format("Uh oh! You failed to meet the deadline on an existing mission by %02i:%02i:%02i h:m:s !\n", missionTimeTable.elapsedTime.hours, missionTimeTable.elapsedTime.minutes, missionTimeTable.elapsedTime.seconds))
 
      end
 
 
     end
 
     end
 
   end
 
   end
 +
  updateMap()
 
end
 
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"
  
-- in use:
+
==addMapMenu==
lua mission(60*60)
+
;addMapMenu(uniquename, parent, display name)
Get cracking, you have 01:00:00 h:m:s left.
 
  
lua mission(60*60)
+
:Adds a new submenu to the right-click menu that opens when you right-click on the mapper. You can then add more submenus to it, or add entries with [[#addMapEvent|addMapEvent()]].
Better hurry up, the clock is ticking on an existing mission and you only have 00:59:52 h:m:s left.
+
: See also: [[#addMapEvent|addMapEvent()]], [[#removeMapEvent|removeMapEvent()]], [[#getMapEvents|getMapEvents()]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- 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")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.4}}
+
==addRoom==
 +
;addRoom(roomID)
  
==ancestors==
+
:Creates a new room with the given ID, returns true if the room was successfully created.
  
;ancestors(IDnumber, type)
+
{{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.
:You can use this function to find out about all the ancestors of something.
+
{{note}} Creating your own mapping script? Check out more [[Manual:Mapper#Making_your_own_mapping_script|information here]].
  
:Returns a list as a table with the details of each successively distance ancestor (if any) of the given item; the details are in the form of a sub-table, within each containing specifically:
+
: See also: [[#createRoomID|createRoomID()]]
:* its IDnumber as a number
 
:* its name as a string
 
:* whether it is active as a boolean
 
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)
 
:Returns ''nil'' and an error message if either parameter is not valid
 
  
;Parameters
+
;Example:
* ''IDnumber:''
+
<syntaxhighlight lang="lua">
: The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
+
local newroomid = createRoomID()
* ''type:''
+
addRoom(newroomid)
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.
+
</syntaxhighlight>
 +
 
 +
==addSpecialExit==
 +
;addSpecialExit(roomIDFrom, roomIDTo, moveCommand)
 +
 
 +
:Creates a one-way from one room to another, that will use the given command for going through them.
  
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]
+
: See also: [[#clearSpecialExits|clearSpecialExits()]], [[#removeSpecialExit|removeSpecialExit()]], [[#setExit|setExit()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- To do
+
-- add a one-way special exit going from room 1 to room 2 using the 'pull rope' command
 +
addSpecialExit(1, 2, "pull rope")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==appendScript==
+
Example in an alias:
;appendScript(scriptName, luaCode, [occurrence])
+
<syntaxhighlight lang="lua">
: Appends Lua code to the script "scriptName". If no occurrence given it sets the code of the first found script.
+
-- sample alias pattern: ^spe (\d+) (.*?)$
 +
-- currentroom is your current room ID in this example
 +
addSpecialExit(currentroom,tonumber(matches[2]), matches[3])
 +
echo("\n SPECIAL EXIT ADDED TO ROOMID:"..matches[2]..", Command:"..matches[3])
 +
centerview(currentroom)
 +
</syntaxhighlight>
  
: See also: [[Manual:Lua_Functions#permScript|permScript()]], [[Manual:Lua_Functions#enableScript|enableScript()]], [[Manual:Lua_Functions#disableScript|disableScript()]], [[Manual:Lua_Functions#getScript|getScript()]], [[Manual:Lua_Functions#setScript|setScript()]]
+
==auditAreas==
 +
;auditAreas()
  
;Returns
+
: 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.
* a unique id number for that script.
+
 
 +
: See also: [[#saveMap|saveMap()]], [[#removeMapEvent|removeMapEvent()]], [[#getMapEvents|getMapEvents()]]
 +
 
 +
==centerview==
 +
;centerview (roomID)
 +
 
 +
:Centers the map view onto the given room ID. The map must be open to see this take effect. This function can also be used to see the map of an area if you know the number of a room there and the area and room are mapped.
 +
 
 +
: See also: [[#getPlayerRoom|getPlayerRoom()]], [[#updateMap|updateMap()]]
 +
 
 +
==clearAreaUserData==
 +
;clearAreaUserData(areaID)
 +
 
 +
; Parameter
 +
* areaID - ID number for area to clear.
  
;Parameters
+
:Clears all user data from a given area. Note that this will not touch the room user data.
* ''scriptName'': name of the script
+
: See also: [[#setAreaUserData|setAreaUserData()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#clearRoomUserData|clearRoomUserData()]]
* ''luaCode'': scripts luaCode to append
 
* ''occurence'': (optional) the occurrence of the script in case you have many with the same name
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- an example of appending the script lua code to the first occurrence of "testscript"
+
display(clearAreaUserData(34))
appendScript("testscript", [[echo("This is a test\n")]], 1)
+
-- I did have data in that area, so it returns:
 +
true
 +
 
 +
display(clearAreaUserData(34))
 +
-- There is no data NOW, so it returns:
 +
false
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.8}}
+
{{MudletVersion|3.0}}
  
==appendCmdLine==
+
==clearAreaUserDataItem==
;appendCmdLine([name], text)
+
;clearAreaUserDataItem(areaID, key)
: Appends text to the main input line.
 
: See also: [[Manual:Lua_Functions#printCmdLine|printCmdLine()]], [[#clearCmdLine|clearCmdLine()]]
 
  
;Parameters
+
:Removes the specific key and value from the user data from a given area.
* ''name'': (optional) name of the command line. If not given, the text will be appended to the main commandline.
+
: See also: [[#setAreaUserData|setAreaUserData()]], [[#clearAreaUserData|clearAreaUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]
* ''text'': text to append
 
  
 +
{{MudletVersion|3.0}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- adds the text "55 backpacks" to whatever is currently in the input line
+
display(getAllAreaUserData(34))
appendCmdLine("55 backpacks")
+
{
 +
  description = [[<area description here>]],
 +
  ruler = "Queen Morgase Trakand"
 +
}
  
-- makes a link, that when clicked, will add "55 backpacks" to the input line
+
display(clearAreaUserDataItem(34,"ruler"))
echoLink("press me", "appendCmdLine'55 backpack'", "Press me!")
+
true
 +
 
 +
display(getAllAreaUserData(34))
 +
{
 +
  description = [[<area description here>]],
 +
}
 +
 
 +
display(clearAreaUserDataItem(34,"ruler"))
 +
false
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==clearCmdLine==
+
==clearMapSelection==
;clearCmdLine([name])
+
;clearMapSelection()
: Clears the input line of any text that's been entered.
+
 
: See also: [[Manual:Lua_Functions#printCmdLine|printCmdLine()]]
+
:Clears any selected rooms from the map (i.e. they are highlighted in orange).
 +
 
 +
:Returns true if rooms are successfully cleared, false if nothing selected or cleared.
 +
 
 +
: See also [[#getMapSelection|getMapSelection()]]
 +
 
 +
==clearMapUserData==
 +
;clearMapUserData()
 +
 
 +
:Clears all user data stored for the map itself. Note that this will not touch the area or room user data.
 +
 
 +
: See also: [[#setMapUserData|setMapUserData()]], [[#clearRoomUserData|clearRoomUserData()]], [[#clearAreaUserData|clearAreaUserData()]]
  
;Parameters
+
{{MudletVersion|3.0}}
* ''name'': (optional) name of the command line. If not given, the main commandline's text will be cleared.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- don't be evil with this!
+
display(clearMapUserData())
clearCmdLine()
+
-- I did have user data stored for the map, so it returns:
 +
true
 +
 
 +
display(clearMapUserData())
 +
-- There is no data NOW, so it returns:
 +
false
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==clearCmdLineSuggestions==
+
==clearMapUserDataItem==
;clearCmdLineSuggestions([name])
+
;clearMapUserDataItem(mapID, key)
  
: Clears all suggestions for command line.
+
:Removes the specific key and value from the user data from the map user data.
 +
: See also: [[#setMapUserData|setMapUserData()]], [[#clearMapUserData|clearMapUserData()]], [[#clearAreaRoomUserData|clearAreaRoomUserData()]]
  
: See also: [[Manual:Lua_Functions#addCmdLineSuggestion|addCmdLineSuggestion()]], [[Manual:Lua_Functions#removeCmdLineSuggestion|removeCmdLineSuggestion()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
display(getAllMapUserData())
 +
{
 +
  description = [[<map description here>]],
 +
  last_modified = "1483228799"
 +
}
  
;Parameter
+
display(clearMapUserDataItem("last_modified"))
* ''name'': (optional) name of the command line. If not given the main commandline's suggestions will be cleared.
+
true
  
<syntaxhighlight lang="lua">
+
display(getAllMapUserData())
clearCmdLineSuggestions()
+
{
 +
  description = [[<map description here>]],
 +
}
 +
 
 +
display(clearMapUserDataItem("last_modified"))
 +
false
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==createStopWatch==
+
{{MudletVersion|3.0}}
;createStopWatch([name], [start immediately])
 
;createStopWatch([start immediately])
 
Before Mudlet 4.4.0:
 
;createStopWatch()
 
  
: This function creates a stopwatch, a high resolution time measurement tool. Stopwatches can be started, stopped, reset, asked how much time has passed since the stop watch has been started and, following an update for Mudlet 4.4.0: be adjusted, given a name and be made persistent between sessions (so can time real-life things). Prior to 4.4.0 the function took no parameters '''and the stopwatch would start automatically when it was created'''.
+
==clearRoomUserData==
 +
;clearRoomUserData(roomID)
  
;Parameters:
+
:Clears all user data from a given room.
* ''start immediately'' (bool) used to override the behaviour prior to Mudlet 4.4.0 so that if it is the ''only'' argument then a ''false'' value will cause the stopwatch to be created but be in a ''stopped'' state, however if a name parameter is provided then this behaviour is assumed and then a ''true'' value is required should it be desired for the stopwatch to be started on creation. This difference between the cases with and without a name argument is to allow for older scripts to continue to work with 4.4.0 or later versions of Mudlet without change, yet to allow for more functionality - such as presetting a time when the stopwatch is created but not to start it counting down until some time afterwards - to be performed as well with a named stopwatch.
+
: See also: [[#setRoomUserData|setRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]]
 +
 
 +
{{note}} Returns a boolean true if any data was removed from the specified room and false if there was nothing to erase since Mudlet 3.0.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
display(clearRoomUserData(3441))
 +
-- I did have data in that room, so it returns:
 +
true
  
* ''name'' (string) a ''unique'' text to use to identify the stopwatch.
+
display(clearRoomUserData(3441))
 +
-- There is no data NOW, so it returns:
 +
false
 +
</syntaxhighlight>
  
;Returns:
+
==clearRoomUserDataItem==
* the ID (number) of a stopwatch; or, from '''4.4.0''': a nil + error message if the name has already been used.
+
;clearRoomUserDataItem(roomID, key)
  
: See also: [[Manual:Lua_Functions#startStopWatch|startStopWatch()]], [[Manual:Lua_Functions#stopStopWatch|stopStopWatch()]], [[Manual:Lua_Functions#resetStopWatch|resetStopWatch()]], [[Manual:Lua_Functions#getStopWatchTime|getStopWatchTime()]] or, from 4.4.0: [[Manual:Lua_Functions#adjustStopWatch|adjustStopWatch()]], [[Manual:Lua_Functions#deleteStopWatch|deleteStopWatch()]], [[Manual:Lua_Functions#getStopWatches|getStopWatches()]], [[Manual:Lua_Functions#getStopWatchBrokenDownTime|getStopWatchBrokenDownTime()]], [[Manual:Lua_Functions#setStopWatchName|setStopWatchName()]], [[Manual:Lua_Functions#setStopWatchPersistence|setStopWatchPersistence()]]
+
:Removes the specific key and value from the user data from a given room.
 +
:Returns a boolean true if data was found against the give key in the user data for the given room and it is removed, will return false if exact key not present in the data. Returns nil if the room for the roomID not found.
 +
: See also: [[#setRoomUserData|setRoomUserData()]], [[#clearRoomUserData|clearRoomUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]]
  
 
;Example
 
;Example
: (Prior to Mudlet 4.4.0) in a global script you can create all stop watches that you need in your system and store the respective stopWatch-IDs in global variables:
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
fightStopWatch = fightStopWatch or createStopWatch() -- create, or re-use a stopwatch, and store the watchID in a global variable to access it from anywhere
+
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
  
-- then you can start the stop watch in some trigger/alias/script with:
+
display(getAllRoomUserData(3441))
startStopWatch(fightStopWatch)
+
{
 +
  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!]],
 +
}
  
-- to stop the watch and measure its time in e.g. a trigger script you can write:
+
display(clearRoomUserDataItem(3441,"doorname_up"))
fightTime = stopStopWatch(fightStopWatch)
+
false
echo("The fight lasted for " .. fightTime .. " seconds.")
 
resetStopWatch(fightStopWatch)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: (From Mudlet 4.4.0) in a global script you can create all stop watches that you need in your system with unique names:
+
{{MudletVersion|3.0}}
<syntaxhighlight lang="lua">
 
createStopWatch("fightStopWatch") -- creates the stopwatch or returns nil+msg if it already exists
 
  
-- then you can start the stop watch (if it is not already started) in some trigger/alias/script with:
+
==clearSpecialExits==
startStopWatch("fightStopWatch")
+
;clearSpecialExits(roomID)  
  
-- to stop the watch and measure its time in e.g. a trigger script you can write:
+
:Removes all special exits from a room.
fightTime = stopStopWatch("fightStopWatch")
+
: See also: [[#addSpecialExit|addSpecialExit()]], [[#removeSpecialExit|removeSpecialExit()]]
echo("The fight lasted for " .. fightTime .. " seconds.")
 
resetStopWatch("fightStopWatch")
 
</syntaxhighlight>
 
  
:You can also measure the elapsed time without having to stop the stop watch (equivalent to getting a ''lap-time'') with [[#getStopWatchTime|getStopWatchTime()]].
+
;Example
 +
<syntaxhighlight lang="lua">
 +
clearSpecialExits(1337)
  
{{note}} it's best to re-use stopwatch IDs if you can for Mudlet prior to 4.4.0 as they cannot be deleted, so creating more and more would use more memory. From 4.4.0 the revised internal design has been changed such that there are no internal timers created for each stopwatch - instead either a timestamp or a fixed elapsed time record is used depending on whether the stopwatches is running or stopped so that there are no "moving parts" in the later design and less resources are used - and they can be removed if no longer required.
+
if #getSpecialExits(1337) == 0 then -- clearSpecialExits will never fail on a valid room ID, this is an example
 +
  echo("All special exits successfully cleared from 1337.\n")
 +
end
 +
</syntaxhighlight>
  
==deleteAllNamedTimers==
+
==closeMapWidget==
; deleteAllNamedTimers(userName)
+
;closeMapWidget()
 +
:closes (hides) the map window (similar to clicking on the map icon)
  
:Deletes all named timers and prevents them from firing any more. Information is deleted and cannot be retrieved.
+
{{MudletVersion|4.7}}
 +
: See also: [[#openMapWidget|openMapWidget()]], [[#moveMapWidget|moveMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
+
==connectExitStub==
 +
;connectExitStub(fromID, direction) or connectExitStub(fromID, toID, [direction])
  
{{MudletVersion|4.14}}
+
:Connects existing rooms with matching exit stubs. If you only give it a roomID and a direction, it'll work out which room should be linked to it that has an appropriate opposite exit stub and is located in the right direction. You can also just specify from and to room IDs, and it'll smartly use the right direction to link in. Lastly, you can specify all three arguments - fromID, toID and the direction (in that order) if you'd like to be explicit, or use [[#setExit|setExit()]] for the same effect.
  
 
;Parameters
 
;Parameters
* ''userName:''
+
* ''fromID:''
: The user name the event handler was registered under.
+
: 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|setExitStub()]], [[#getExitStubs|getExitStubs()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
deleteAllNamedTimers("Demonnic") -- emergency stop or debugging situation, most likely.
+
-- try and connect all stubs that are in a room
 +
local stubs = getExitStubs(roomID)
 +
if stubs then
 +
  for i,v in pairs(stubs) do
 +
    connectExitStub(roomID, v)
 +
  end
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==deleteNamedTimer==
+
==createMapLabel==
; success = deleteNamedTimer(userName, handlerName)
+
;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.
  
:Deletes a named timer with name handlerName and prevents it from firing any more. Information is deleted and cannot be retrieved.
+
: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: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
+
: See also: [[#getMapLabel|getMapLabel()]], [[#getMapLabels|getMapLabels()]], [[#deleteMapLabel|deleteMapLabel]], [[#createMapUmageLabel|createMapImageLabel()]]
  
{{MudletVersion|4.14}}
+
{{note}} Some changes were done prior to 4.13 (which exactly? function existed before!) - see corresponding PR and update here!
  
 
;Parameters
 
;Parameters
* ''userName:''
+
* ''areaID:''
: The user name the event handler was registered under.
+
: Area ID where to put the label.
* ''handlerName:''
+
* ''text:''
: The name of the handler to stop. Same as used when you called [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
+
: 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.
  
;Returns
 
* true if successful, false if it didn't exist
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local deleted = deleteNamedTimer("Demonnic", "DemonVitals")
+
-- the first 50 is some area id, the next three 0,0,0 are coordinates - middle of the area
if deleted then
+
-- 255,0,0 would be the foreground in RGB, 23,0,0 would be the background RGB
  cecho("DemonVitals deleted forever!!")
+
-- zoom is only relevant when when you're using a label of a static size, so we use 0
else
+
-- and we use a font size of 20 for our label, which is a small medium compared to the map
  cecho("DemonVitals doesn't exist and so could not be deleted.")
+
local labelid = createMapLabel( 50, "my map label", 0,0,0, 255,0,0, 23,0,0, 0,20)
end
+
 
 +
-- 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)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==deleteStopWatch==
+
==createMapImageLabel==
;deleteStopWatch(watchID/watchName)
+
;labelID = createMapImageLabel(areaID, filePath, posx, posy, posz, width, height, zoom, showOnTop[, temporary])
  
: This function removes an existing stopwatch, whether it only exists for this session or is set to be otherwise saved between sessions by using [[Manual:Lua_Functions#setStopWatchPersistence|setStopWatchPersistence()]] with a ''true'' argument.
+
: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.
  
;Parameters
+
: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.
* ''watchID'' (number) / ''watchName'' (string): The stopwatch ID you get with [[Manual:Lua_Functions#createStopWatch|createStopWatch()]] or the name given to that function or later set with [[Manual:Lua_Functions#setStopWatchName|setStopWatchName()]].
+
: See also: [[#createMapLabel|createMapLabel]], [[#deleteMapLabel|deleteMapLabel]]
 
 
;Returns:
 
* ''true'' if the stopwatch was found and thus deleted, or ''nil'' and an error message if not - obviously using it twice with the same argument will fail the second time unless another one with the same name or ID was recreated before the second use.  Note that an empty string as a name ''will'' find the lowest ID numbered ''unnamed'' stopwatch and that will then find the next lowest ID number of unnamed ones until there are none left, if used repetitively!
 
  
 +
;Example:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
lua MyStopWatch = createStopWatch("stopwatch_mine")
+
-- 138 is our pretend area ID
true
+
-- next, inside [[]]'s, is the exact location of our image
 +
-- 0,0,0 are the x,y,z coordinates - so this will place it in the middle of the map
 +
-- 482 is the width of the image - we divide it by 100 to scale it down, and then we'll zoom it by 100 - making the image take up about 4 rooms in width then
 +
-- 555 is the original height of the image
 +
-- 100 is how much we zoom it by, 1 would be no zoom
 +
-- false to make it go below our rooms
 +
-- (from 4.17.0) true to not save the label's image in the map file afterwards
 +
createMapImageLabel(138, [[/home/vadi/Pictures/You only see what shown.png]], 0,0,0, 482/100, 555/100, 100, false, true)
 +
</syntaxhighlight>
  
lua display(MyStopWatch)
+
==createMapper==
4
+
;createMapper([name of userwindow], x, y, width, height)
  
lua deleteStopWatch(MyStopWatch)
+
: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.
true
 
  
lua deleteStopWatch(MyStopWatch)
+
{{note}} ''name of userwindow'' available in Mudlet 4.6.1+
nil
 
  
"stopwatch with id 4 not found"
+
{{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.
  
lua deleteStopWatch("stopwatch_mine")
+
;Example
nil
+
<syntaxhighlight lang="lua">
 +
createMapper(0,0,300,300) -- creates a 300x300 mapper in the top-left corner of Mudlet
 +
setBorderLeft(305) -- adds a border so text doesn't underlap the mapper display
 +
</syntaxhighlight>
  
"stopwatch with name "stopwatch_mine" not found"
+
<syntaxhighlight lang="lua">
 +
-- another example:
 +
local main = Geyser.Container:new({x=0,y=0,width="100%",height="100%",name="mapper container"})
 +
 +
local mapper = Geyser.Mapper:new({
 +
  name = "mapper",
 +
  x = "70%", y = 0, -- edit here if you want to move it
 +
  width = "30%", height = "50%"
 +
}, main)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: See also: [[Manual:Lua_Functions#createStopWatch|createStopWatch()]],
+
==createRoomID==
 +
;usableId = createRoomID([minimumStartingRoomId])
  
{{MudletVersion|4.4}}
+
: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.  
  
{{note}} Stopwatches that are not set to be persistent will be deleted automatically at the end of a session (or if [[Manual:Miscellaneous_Functions#resetProfile|resetProfile()]] is called).
+
;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.
  
==removeCmdLineSuggestion==
+
: See also: [[#addRoom|addRoom()]]
;removeCmdLineSuggestion([name], suggestion)
 
: Remove a suggestion for tab completion for specified command line.
 
  
: See also: [[Manual:Lua_Functions#addCmdLineSuggestion|addCmdLineSuggestion()]], [[Manual:Lua_Functions#clearCmdLineSuggestions|clearCmdLineSuggestions()]]
+
==deleteArea==
 +
;deleteArea(areaID or areaName)
  
{{MudletVersion|4.11}}
+
:Deletes the given area and all rooms in it. Returns ''true'' on success or ''nil'' + ''error message'' otherwise.
 +
: See also: [[#addAreaName|addAreaName()]]
  
 
;Parameters
 
;Parameters
* ''name'': optional command line name, if skipped main command line will be used
+
* ''areaID:''
* ''suggestion'' - text to add to tab completion, non words characters at start and end of word should not be used (all characters except: `0-9A-Za-z_`)
+
: Area ID to delete, or:
 +
* ''areaName'' (available in Mudlet 3.0+):
 +
: Area name to delete.
  
Example:
+
 
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
removeCmdLineSuggestion("help")
+
-- delete by areaID
 +
deleteArea(23)
 +
-- or since Mudlet 3.0, by area name
 +
deleteArea("Big city")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==disableAlias==
+
==deleteMap==
;disableAlias(name)
+
;deleteMap()
:Disables/deactivates the alias by its name. If several aliases have this name, they'll all be disabled. If you disable an alias group, all the aliases inside the group will be disabled as well.
 
  
: See also: [[#enableAlias|enableAlias()]], [[#disableTrigger|disableTrigger()]], [[#disableTimer|disableTimer()]], [[#disableKey|disableKey()]], [[#disableScript|disableScript()]].
+
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()]]
  
;Parameters
+
{{MudletVersion|4.14.0}}
* ''name:''
+
 
: The name of the alias. Passed as a string.
+
;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.
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--Disables the alias called 'my alias'
+
deleteMap()
disableAlias("my alias")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==disableKey==
+
==deleteMapLabel==
;disableKey(name)
+
;deleteMapLabel(areaID, labelID)
:Disables key a key (macro) or a key group. When you disable a key group, all keys within the group will be implicitly disabled as well.
 
  
: See also: [[#enableKey|enableKey()]]
+
:Deletes a map label from  a specific area.
 +
: See also: [[#createMapLabel|createMapLabel()]]
  
;Parameters
+
;Example
* ''name:''
+
<syntaxhighlight lang="lua">
: The name of the key or group to identify what you'd like to disable.
+
deleteMapLabel(50, 1)
 +
</syntaxhighlight>
 +
 
 +
==deleteRoom==
 +
;deleteRoom(roomID)
  
;Examples
+
:Deletes an individual room, and unlinks all exits leading to and from it.
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- you could set multiple keys on the F1 key and swap their use as you wish by disabling and enabling them
+
deleteRoom(335)
disableKey("attack macro")
 
disableKey("jump macro")
 
enableKey("greet macro")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==disableScript==
+
==disableMapInfo==
;disableScript(name)
+
;disableMapInfo(label)
:Disables a script that was previously enabled. Note that disabling a script only stops it from running in the future - it won't "undo" anything the script has made, such as labels on the screen.
 
  
: See also: [[#permScript|permScript()]], [[#appendScript|appendScript()]], [[#enableScript|enableScript()]], [[#getScript|getScript()]], [[#setScript|setScript()]]
+
Disable the particular map info - same as toggling off checkbox from select box under mapper.
  
 
;Parameters
 
;Parameters
* ''name'': name of the script.
+
* ''label:''
 +
: Name under which map info to be disabled was registered.
 +
 
 +
: See also: [[#registerMapInfo|registerMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#killMapInfo|killMapInfo()]]
 +
 
 +
{{MudletVersion|4.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|registerMapInfo()]], [[#disableMapInfo|disableMapInfo()]], [[#killMapInfo|killMapInfo()]]
 +
 
 +
{{MudletVersion|4.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|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#searchAreaUserData|searchAreaUserData()]], [[#setAreaUserData|setAreaUserData()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--Disables the script called 'my script'
+
display(getAllAreaUserData(34))
disableScript("my script")
+
--might result in:--
 +
{
 +
  country = "Andor",
 +
  ruler = "Queen Morgase Trakand"
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.8}}
+
{{MudletVersion|3.0}}
  
==disableTimer==
+
==getAllMapUserData==
;disableTimer(name)
+
;dataTable = getAllMapUserData()
:Disables a timer from running it’s script when it fires - so the timer cycles will still be happening, just no action on them. If you’d like to permanently delete it, use [[Manual:Lua_Functions#killTrigger|killTrigger]] instead.
 
  
: See also: [[#enableTimer|enableTimer()]], [[#disableTrigger|disableTrigger()]], [[#disableAlias|disableAlias()]], [[#disableKey|disableKey()]], [[#disableScript|disableScript()]].
+
: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()]]
* ''name:''
 
: Expects the timer ID that was returned by [[Manual:Lua_Functions#tempTimer|tempTimer]] on creation of the timer or the name of the timer in case of a GUI timer.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--Disables the timer called 'my timer'
+
display(getAllMapUserData())
disableTimer("my timer")
+
--might result in:--
 +
{
 +
  description = [[This map is about so and so game]],
 +
  author = "Bob",
 +
  ["last updated"] = "December 5, 2020"
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==disableTrigger==
+
{{MudletVersion|3.0}}
;disableTrigger(name)
 
:Disables a permanent (one in the trigger editor) or a temporary trigger. When you disable a group, all triggers inside the group are disabled as well
 
  
: See also: [[#enableTrigger|enableTrigger()]], [[#disableAlias|disableAlias()]], [[#disableTimer|disableTimer()]], [[#disableKey|disableKey()]], [[#disableScript|disableScript()]].
+
==getAllRoomEntrances==
 +
;exitsTable = getAllRoomEntrances(roomID)
  
;Parameters
+
: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.
* ''name:''
+
 
: Expects the trigger ID that was returned by [[Manual:Lua_Functions#tempTrigger|tempTrigger]] or other temp*Trigger variants, or the name of the trigger in case of a GUI trigger.
+
{{MudletVersion|3.0}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Disables the trigger called 'my trigger'
+
-- print the list of rooms that have exits leading into room 512
disableTrigger("my trigger")
+
for _, roomid in ipairs(getAllRoomEntrances(512)) do
 +
  print(roomid)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==enableAlias==
+
: See also: [[#getRoomExits|getRoomExits()]]
;enableAlias(name)
 
:Enables/activates the alias by it’s name. If several aliases have this name, they’ll all be enabled.
 
  
: See also: [[#disableAlias|disableAlias()]]
+
==getAllRoomUserData==
 +
;dataTable = getAllRoomUserData(roomID)
  
;Parameters
+
: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!''
* ''name:''
+
 
: Expects the alias ID that was returned by [[Manual:Lua_Functions#tempAlias|tempAlias]] on creation of the alias or the name of the alias in case of a GUI alias.
+
;See also: [[#getRoomUserDataKeys|getRoomUserDataKeys()]] - for a related command that only returns the data keys.
 +
 
 +
{{MudletVersion|3.0}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--Enables the alias called 'my alias'
+
display(getAllRoomUserData(3441))
enableAlias("my alias")
+
--might result in:--
 +
{
 +
  description = [[
 +
From this ledge you can see out across a large cavern to the southwest. The
 +
east side of the cavern is full of stalactites and stalagmites and other
 +
weird rock formations. The west side has a path through it and an exit to the
 +
south. The sound of falling water pervades the cavern seeming to come from
 +
every side. There is a small tunnel to your east and a stalactite within arms
 +
reach to the south. It appears to have grown till it connects with the
 +
stalagmite below it. Something smells... Yuck you are standing in bat guano!]],
 +
  doorname_up = "trapdoor"
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==enableKey==
+
==getAreaExits==
;enableKey(name)
+
;roomTable = getAreaExits(areaID, showExits)
:Enables a key (macro) or a group of keys (and thus all keys within it that aren't explicitly deactivated).
+
 
 +
: Returns a table (indexed or key-value) of the rooms in the given area that have exits leading out to other areas - that is, border rooms.
 +
 
 +
;See also: [[#setExit|setExit()]], [[#getRoomExits|getRoomExits()]]
  
 
;Parameters
 
;Parameters
* ''name:''
+
* ''areaID:''
: The name of the group that identifies the key.
+
: 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
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- you could use this to disable one key set for the numpad and activate another
+
-- list all border rooms for area 44:
disableKey("fighting keys")
+
getAreaExits(44)
enableKey("walking keys")
+
 
 +
-- 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
 +
  }
 +
}
 +
]]
 
</syntaxhighlight>
 
</syntaxhighlight>
{{note}} From Version '''3.10'' returns ''true'' if one or more keys or groups of keys were found that matched the name given or ''false'' if not; prior to then it returns ''true'' if there were '''any''' keys - whether they matched the name or not!
 
  
==enableScript==
+
==getAreaRooms==
;enableScript(name)
+
;getAreaRooms(area id)
:Enables / activates a script that was previously disabled.
 
  
: See also: [[#permScript|permScript()]], [[#appendScript|appendScript()]], [[#disableScript|disableScript()]], [[#getScript|getScript()]], [[#setScript|setScript()]]
+
:Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or ''nil'' if no such area exists.
  
;Parameters
+
;Example
* ''name'': name of the script.
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- enable the script called 'my script' that you created in Mudlet's script section
+
-- using the sample findAreaID() function defined in the getAreaTable() example,
enableScript("my script")
+
-- 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
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.8}}
+
==getAreaTable==
 +
;areaTable = getAreaTable()
  
==enableTimer==
+
:Returns a key(area name)-value(area id) table with all known areas and their IDs.
;enableTimer(name)
+
{{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.
:Enables or activates a timer that was previously disabled.  
 
  
;Parameters
+
;See also: [[#getAreaTableSwap|getAreaTableSwap()]]
* ''name:''
 
: Expects the timer ID that was returned by [[Manual:Lua_Functions#tempTimer|tempTimer]] on creation of the timer or the name of the timer in case of a GUI timer.
 
<syntaxhighlight lang="lua">
 
-- enable the timer called 'my timer' that you created in Mudlets timers section
 
enableTimer("my timer")
 
</syntaxhighlight>
 
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- or disable & enable a tempTimer you've made
+
-- example function that returns the area ID for a given area
timerID = tempTimer(10, [[echo("hi!")]])
 
  
-- it won't go off now
+
function findAreaID(areaname)
disableTimer(timerID)
+
  local list = getAreaTable()
-- it will continue going off again
 
enableTimer(timerID)
 
</syntaxhighlight>
 
  
==enableTrigger==
+
  -- iterate over the list of areas, matching them with substring match.
;enableTrigger(name)
+
  -- if we get match a single area, then return it's ID, otherwise return
:Enables or activates a trigger that was previously disabled.
+
  -- '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
  
;Parameters
+
-- sample use:
* ''name:''
+
local id, msg = findAreaID("blahblah")
: Expects the trigger ID that was returned by [[Manual:Lua_Functions#tempTrigger|tempTrigger]] or by any other temp*Trigger variants, or the name of the trigger in case of a GUI trigger.
+
if id then
<syntaxhighlight lang="lua">
+
  echo("Found a matching ID: " .. id)
-- enable the trigger called 'my trigger' that you created in Mudlets triggers section
+
elseif not id and msg then
enableTrigger("my trigger")
+
  echo("ID not found: " .. msg)
 +
else
 +
  echo("No areas matched the query.")
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
==getAreaTableSwap==
-- or disable & enable a tempTrigger you've made
+
;areaTable = getAreaTableSwap()
triggerID = tempTrigger("some text that will match in a line", [[echo("hi!")]])
 
  
-- it won't go off now when a line with matching text comes by
+
: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.
disableTrigger(triggerID)
+
{{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.
  
-- and now it will continue going off again
+
==getAreaUserData==
enableTrigger(triggerID)
+
;dataValue = getAreaUserData(areaID, key)
</syntaxhighlight>
 
  
==exists==
+
: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.)
;exists(name/IDnumber, type)
 
:Returns the number of things with the given name or number of the given type - and 0 if none are present. Beware that all numbers are true in Lua, including zero.
 
  
;Parameters
+
: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.
* ''name:''
 
: The name (as a string) or, from '''Mudlet 4.17.0''', the ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 
* ''type:''
 
: The type can be 'alias', 'button' (Mudlet 4.10+), 'trigger', 'timer', 'keybind' (Mudlet 3.2+), or 'script' (Mudlet 3.17+).
 
  
:See also: [[#isActive|isActive(...)]]
+
;See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]], [[#setAreaUserData|setAreaUserData()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
echo("I have " .. exists("my trigger", "trigger") .. " triggers called 'my trigger'!")
+
display(getAreaUserData(34, "country"))
 +
-- might produce --
 +
"Andor"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
: You can also use this alias to avoid creating duplicate things, for example:
+
==getCustomEnvColorTable==
<syntaxhighlight lang="lua">
+
;envcolors = getCustomEnvColorTable()
-- this code doesn't check if an alias already exists and will keep creating new aliases
 
permAlias("Attack", "General", "^aa$", [[send ("kick rat")]])
 
  
-- while this code will make sure that such an alias doesn't exist first
+
:Returns a table with customized environments, where the key is the environment ID and the value is a indexed table of rgb values.
-- we do == 0 instead of 'not exists' because 0 is considered true in Lua
+
: See also: [[#setCustomEnvColor|setCustomEnvColor()]]
if exists("Attack", "alias") == 0 then
 
    permAlias("Attack", "General", "^aa$", [[send ("kick rat")]])
 
end
 
</syntaxhighlight>
 
  
: Especially helpful when working with [[Manual:Lua_Functions#permTimer|permTimer]]:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
if not exists("My animation timer", "timer") then
+
{
   vdragtimer = permTimer("My animation timer", "", .016, onVDragTimer) -- 60fps timer!
+
  envid1 = {r, g, b, alpha},
end
+
   envid2 = {r, g, b, alpha}
+
}
enableTimer("My animation timer")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{Note}} A positive ID number will return either a ''1'' or ''0'' value and not a lua boolean ''true'' or ''false'' as might otherwise be expected, this is for constancy with the way the function behaves for a name.
+
==getCustomLines==
 +
;lineTable = getCustomLines(roomID)
 +
: See also: [[#addCustomLine|addCustomLine()]], [[#removeCustomLine|removeCustomLine()]]
  
==findItems==
+
:Returns a table including all the details of the custom exit lines, if any, for the room with the id given.
  
;findItems("name", "type"[, exact[, case sensitive]])
+
;Parameters
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.
+
* ''roomID:''
 +
: Room ID to return the custom line details of.
  
:Returns a list as a table with ids of each Mudlet item that matched or ''nil'' and an error message should an incorrect type string be given.
+
{{MudletVersion|3.0.}}
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
display getCustomLines(1)
 +
{
 +
  ["climb Rope"] = {
 +
    attributes = {
 +
      color = {
 +
        b = 0,
 +
        g = 128,
 +
        r = 128
 +
      },
 +
      style = "dash dot dot line",
 +
      arrow = false
 +
    },
 +
    points = {
 +
      {
 +
        y = 9.5,
 +
        x = 4.5
 +
      },
 +
      {
 +
        y = 9.5,
 +
        x = 6
 +
      },
 +
      [0] = {
 +
        y = 5.5,
 +
        x = 4.5
 +
      }
 +
    }
 +
  },
 +
  N = {
 +
    attributes = {
 +
      color = {
 +
        b = 255,
 +
        g = 255,
 +
        r = 0
 +
      },
 +
      style = "dot line",
 +
      arrow = true
 +
    },
 +
    points = {
 +
      [0] = {
 +
        y = 27,
 +
        x = -3
 +
      }
 +
    }
 +
  }
 +
}
 +
</syntaxhighlight>
 +
 
 +
==getCustomLines1==
 +
;lineTable = getCustomLines1(roomID)
 +
This is a replacement for ''getCustomLines(...)'' that outputs the tables for the coordinates for the points on the custom line in an order and format that can be fed straight back into an ''addCustomLine(...)'' call; similarly the color parameters are also reported in the correct format to also be reused in the same manner. This function is intended to make it simpler for scripts to manipulate such lines.
 +
:See also: [[Manual:Mapper_Functions#addCustomLine|addCustomLine()]], [[Manual:Mapper_Functions#removeCustomLine|removeCustomLine()]], [[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]
 +
{{MudletVersion| 4.16}}
  
 
;Parameters
 
;Parameters
* ''name:''
+
* ''roomID:''
:The name (as a string) of the item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
+
:Room ID to return the custom line details of.
* ''type:''
+
 
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.
+
;Returns
* ''exact:''
+
:a table including all the details of the custom exit lines, if any, for the room with the id given.
:(Optional) a boolean which if omitted or ''true'' specifies to match the given name against the whole of the names for items or only as a sub-string of them. As a side effect, if this is provided and is ''false'' and an empty string (i.e. ''""'') is given as the first argument then the function will return the ID numbers of ''all'' items (both temporary and permanent) of the given type in existence at the time.
 
* ''case sensitive:''
 
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.
 
  
 
;Example
 
;Example
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:
+
<syntaxhighlight lang="lua">
==getButtonState==
+
display getCustomLines1(1)
;getButtonState([ButtonNameOrID])
+
{
:This function can be used within checkbox button scripts (2-state buttons) to determine the current state of the checkbox.
+
  ["climb Rope"] = {
 +
    attributes = {
 +
      color = { 128, 128, 0 },
 +
      style = "dash dot dot line",
 +
      arrow = false
 +
    },
 +
    points = { { 4.5, 5.5, 3 }, { 4.5, 9.5, 3 }, { 6, 9.5, 3 } }
 +
  },
 +
  N = {
 +
    attributes = {
 +
      color = { 0, 255, 255 },
 +
      style = "dot line",
 +
      arrow = true
 +
    },
 +
    points = { { -3, 27, 3 } }
 +
  }
 +
}
 +
</syntaxhighlight>
  
: See also: [[#setButtonState|setButtonState()]].
+
==getDoors==
{{note}} Function can be used in any Mudlet script outside of a button's own script with parameter ButtonNameOrID available from Mudlet version 4.13.0+
+
;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
 
;Parameters
* ''ButtonNameOrID:''
+
* ''roomID:''
: a numerical ID or string name to identify the checkbox button.
+
: Room ID to check for doors in.
  
;Returns
+
: See also: [[#setDoor|setDoor()]]
* ''2'' if the button has "checked" state, or ''1'' if the button is not checked. (or a ''nil'' and an error message if ButtonNameOrID did not identify a check-able button)
 
  
;Example  
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- check from within the script of a check-able button:
+
-- an example that displays possible doors in room 2334
local checked = getButtonState()
+
local doors = getDoors(2334)
if checked == 1 then
+
 
    hideExits()
+
if not next(doors) then cecho("\nThere aren't any doors in room 2334.") return end
else
+
 
    showExits()
+
local door_status = {"open", "closed", "locked"}
end
 
</syntaxhighlight>
 
  
<syntaxhighlight lang="lua">
+
for direction, door in pairs(doors) do
-- check from anywhere in another Lua script of the same profile (available from Mudlet 4.13.0)
+
  cecho("\nThere's a door leading in "..direction.." that is "..door_status[door]..".")
local checked, errMsg = getButtonState("Sleep")
 
if checked then
 
    shouldBeMounted = shouldBeMounted or false
 
    sendAll("wake", "stand")
 
    if shouldBeMounted then
 
        send("mount horse")
 
    end
 
else
 
    -- Global used to record if we were on a horse before our nap:
 
    shouldBeMounted = mounted or false
 
    if shouldBeMounted then
 
        send("dismount")
 
    end
 
    sendAll("sit", "sleep")
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getCmdLine==
+
==getExitStubs==
;getCmdLine([name])
+
;stubs = getExitStubs(roomid)
: Returns the current content of the given command line.
 
: See also: [[Manual:Lua_Functions#printCmdLine|printCmdLine()]]
 
  
{{MudletVersion|3.1}}
+
: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.
  
;Parameters
+
: See also: [[#setExitStub|setExitStub()]], [[#connectExitStub|connectExitStub()]], [[#getExitStubs1|getExitStubs1()]]
* ''name'': (optional) name of the command line. If not given, it returns the text of the main commandline.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- replaces whatever is currently in the input line by "55 backpacks"
+
-- show the exit stubs in room 6 as numbers
printCmdLine("55 backpacks")
+
local stubs = getExitStubs(6)
 +
for i = 0, #stubs do print(stubs[i]) end
 +
</syntaxhighlight>
  
--prints the text "55 backpacks" to the main console
+
{{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.
echo(getCmdLine())
+
 
</syntaxhighlight>
+
==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.
  
==getConsoleBufferSize==
+
; See also: [[#getExitStubs|getExitStubs()]]
;local lineLimit, sizeOfBatchDeletion = getConsoleBufferSize([consoleName])
 
:Returns, on success, the maximum number of lines a buffer (main window or a miniconsole) can hold and how many will be removed at a time when that limit is exceeded; returns a ''nil'' and an error message on failure.
 
: See also: [[Manual:Mudlet_Object_Functions#setConsoleBufferSize|setConsoleBufferSize()]]
 
  
;Parameters
 
* ''consoleName:''
 
: (optional) The name of the window. If omitted, uses the main console.
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- sets the main window's size and how many lines will be deleted
+
-- show the exit stubs in room 6 as numbers
-- when it gets to that size to be as small as possible:
+
for k,v in ipairs(getExitStubs1(6)) do print(k,v) end
setConsoleBufferSize("main", 1, 1)
+
</syntaxhighlight>
true
 
  
-- find out what the numbers are:
+
==getExitWeights==
local lineLimit, sizeOfBatchDeletion = getConsoleBufferSize()
+
;weights = getExitWeights(roomid)
echo("\nWhen the main console gets to " .. lineLimit .. " lines long, the first " .. sizeOfBatchDeletion .. " lines will be removed.\n")
 
When the main console gets to 100 lines long, the first 1 lines will be removed.
 
</syntaxhighlight>
 
  
{{MudletVersion|4.17}}
+
: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.
  
==getNamedTimers==
+
;Parameters
; timers = getNamedTimers(userName)
+
* ''roomid:''
 +
: Room ID to view the exit weights in.
  
:Returns a list of all the named timers' names as a table.
+
: See also: [[#setExitWeight|setExitWeight()]]
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
+
==getGridMode==
 +
;TrueOrFalse = getGridMode(areaID)
  
{{MudletVersion|4.14}}
+
:Use this to see, if a specific area has grid/wilderness view mode set. This way, you can also calculate from a script, how many grid areas a map has got in total.
 +
 
 +
{{MudletVersion|3.11}}
  
 
;Parameters
 
;Parameters
* ''userName:''
+
* ''areaID:''
: The user name the event handler was registered under.
+
: Area ID (number) to view the grid mode of.
  
;Returns
+
: See also: [[#setGridMode|setGridMode()]]
* a table of handler names. { "DemonVitals", "DemonInv" } for example. {} if none are registered
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
  local timers = getNamedTimers("Demonnic")
+
getGridMode(55)
  display(timers)
+
-- will return: false
  -- {}
+
setGridMode(55, true) -- set area with ID 55 to be in grid mode
  registerNamedTimer("Test1", "testEvent", "testFunction")
+
getGridMode(55)
  registerNamedTimer("Test2", "someOtherEvent", myHandlerFunction)
+
-- will return: true
  timers = getNamedTimers("Demonnic")
 
  display(timers)
 
  -- { "Test1", "Test2" }
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== getProfileStats==
+
==getMapEvents==
;getProfileStats()
+
; mapevents = getMapEvents()
 
 
:Returns a table with profile statistics for how many triggers, patterns within them, aliases, keys, timers, and scripts the profile has. Similar to the Statistics button in the script editor, accessible to Lua scripting.
 
  
{{MudletVersion|4.15}}
+
: 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|addMapMenu()]], [[#removeMapEvent|removeMapEvent()]], [[#addMapEvent|addMapEvent()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- show all stats
+
addMapEvent("room a", "onFavorite") -- will make a label "room a" on the map menu's right click that calls onFavorite
display(getProfileStats())
 
  
-- check how many active triggers there are
+
addMapEvent("room b", "onFavorite", "Favorites", "Special Room!", 12345, "arg1", "arg2", "argn")
activetriggers = getProfileStats().triggers.active
 
cecho(f"<PaleGreen>We have <SlateGrey>{activetriggers}<PaleGreen> active triggers!\n")
 
  
-- triggers can have many patterns, so let's check that as well
+
local mapEvents = getMapEvents()
patterns = getProfileStats().triggers.patterns.active
+
for _, event in ipairs(mapEvents) do
triggers = getProfileStats().triggers.active
+
  echo(string.format("MapEvent '%s' is bound to event '%s' with these args: '%s'", event["uniquename"], event["event name"], table.concat(event["arguments"], ",")))
cecho(f"<PaleGreen>We have <SlateGrey>{patterns}<PaleGreen> active patterns within <SlateGrey>{triggers}<PaleGreen> triggers!\n")
+
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getStopWatches==
+
{{MudletVersion|3.3}}
;table = getStopWatches()
+
 
 +
==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.
  
: Returns a table of the details for each stopwatch in existence, the keys are the watch IDs but since there can be gaps in the ID number allocated for the stopwatches it will be necessary to use the ''pairs(...)'' rather than the ''ipairs(...)'' method to iterate through all of them in ''for'' loops!
+
:''BgColor'' and ''FgColor'' are tables with ''r'',''g'',''b'' keys, each holding ''0-255'' color component value.
: Each stopwatch's details will list the following items: ''name'' (string), ''isRunning'' (boolean), ''isPersistent'' (boolean), ''elapsedTime'' (table). The last of these contains the same data as is returned by the results table from the [[Manual:Lua_Functions#getStopWatchBrokenDownTime|getStopWatchBrokenDownTime()]] function - namely ''days'' (positive integer), ''hours'' (integer, 0 to 23), ''minutes'' (integer, 0 to 59), ''second'' (integer, 0 to 59), ''milliSeconds'' (integer, 0 to 999), ''negative'' (boolean) with an additional ''decimalSeconds'' (number of seconds, with a decimal portion for the milli-seconds and possibly a negative sign, representing the whole elapsed time recorded on the stopwatch) - as would also be returned by the [[Manual:Lua_Functions#getStopWatchTime|getStopWatchTime()]] function.
+
 
 +
:''Pixmap'' is base64 encoded image of label.
 +
 
 +
{{note}} ''BgColor'', ''FgColor'', ''Pixmap'' are available in Mudlet 4.11+
 +
 
 +
;Parameters
 +
* ''areaID:'' areaID from which to retrieve label
 +
* ''labelID:'' labelID (''getMapLabels'' return table key) or labelText (exact match)
 +
 
 +
See also: [[#createMapLabel|createMapLabel()]], [[#getMapLabels|getMapLabels()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- on the command line:
+
lua getMapLabels(52)
lua getStopWatches()
+
{
-- could return something like:
+
  "no text",
 +
  [0] = "test"
 +
}
 +
 
 +
lua getMapLabel(52, 0)
 
{
 
{
   {
+
   Y = -2,
    isPersistent = true,
+
  X = -8,
    elapsedTime = {
+
  Z = 11,
      minutes = 15,
+
  Height = 3.9669418334961,
      seconds = 2,
+
  Text = "test",
      negative = false,
+
  Width = 8.6776866912842,
      milliSeconds = 66,
+
  BgColor = {
      hours = 0,
+
    b = 0,
      days = 18,
+
    g = 0,
      decimalSeconds = 1556102.066
+
    r = 0
     },
+
  },
     name = "Playing time",
+
  FgColor = {
     isRunning = true
+
     b = 50,
 +
     g = 255,
 +
     r = 255
 
   },
 
   },
   {
+
   Pixmap = "iVBORw0KG(...)lFTkSuQmCC" -- base64 encoded png image (shortened for brevity)
    isPersistent = true,
+
}
    elapsedTime = {
+
 
      minutes = 47,
+
lua getMapLabel(52, "no text")
      seconds = 1,
+
{
      negative = true,
+
  Y = 8,
      milliSeconds = 657,
+
  X = -15,
      hours = 23,
+
  Z = 11,
      days = 2,
+
  Height = 7.2520666122437,
      decimalSeconds = -258421.657
+
  Text = "no text"
     },
+
  Width = 11.21900844574,
     name = "TMC Vote",
+
  BgColor = {
     isRunning = true
+
     b = 0,
 +
     g = 0,
 +
     r = 0
 
   },
 
   },
   {
+
   FgColor = {
     isPersistent = false,
+
     b = 50,
    elapsedTime = {
+
     g = 255,
      minutes = 26,
+
     r = 255
      seconds = 36,
 
      negative = false,
 
      milliSeconds = 899,
 
      hours = 3,
 
      days = 0,
 
      decimalSeconds = 12396.899
 
    },
 
     name = "",
 
     isRunning = false
 
 
   },
 
   },
   [5] = {
+
   Pixmap = "iVBORw0KG(...)lFTkSuQmCC" -- base64 encoded png image (shortened for brevity)
    isPersistent = false,
 
    elapsedTime = {
 
      minutes = 0,
 
      seconds = 38,
 
      negative = false,
 
      milliSeconds = 763,
 
      hours = 0,
 
      days = 0,
 
      decimalSeconds = 38.763
 
    },
 
    name = "",
 
    isRunning = true
 
  }
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.4}}
+
==getMapLabels==
 +
;arealabels = getMapLabels(areaID)
  
==getStopWatchTime==
+
: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.
;time = getStopWatchTime(watchID [or watchName from Mudlet 4.4.0])
+
:If there are no labels in the area at all, it will return an empty table.
: Returns the time as a decimal number of seconds with up to three decimal places to give a milli-seconds (thousandths of a second) resolution.
 
: Please note that, prior to 4.4.0 it was not possible to retrieve the elapsed time after the stopwatch had been stopped, retrieving the time was not possible as the returned value then was an indeterminate, meaningless time; from the 4.4.0 release, however, the elapsed value can be retrieved at any time, even if the stopwatch has not been started since creation or modified with the [[Manual:Lua_Functions#adjustStopWatch|adjustStopWatch()]] function introduced in that release.
 
  
: See also: [[Manual:Lua_Functions#createStopWatch|createStopWatch()]], [[Manual:Lua_Functions#startStopWatch|startStopWatch()]], [[Manual:Lua_Functions#stopStopWatch|stopStopWatch()]], [[Manual:Lua_Functions#deleteStopWatch|deleteStopWatch()]], [[Manual:Lua_Functions#getStopWatch es|getStopWatches()]], [[Manual:Lua_Functions#getStopWatchBrokenDownTime|getStopWatchBrokenDownTime()]].
+
: See also: [[#createMapLabel|createMapLabel()]], [[#getMapLabel|getMapLabel()]], [[#deleteMapLabel|deleteMapLabel()]]
 
 
:Returns a number
 
 
 
;Parameters
 
* ''watchID''
 
: The ID number of the watch.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- an example of showing the time left on the stopwatch
+
display(getMapLabels(43))
teststopwatch = teststopwatch or createStopWatch()
+
table {
startStopWatch(teststopwatch)
+
  0: ''
echo("Time on stopwatch: "..getStopWatchTime(teststopwatch))
+
  1: 'Waterways'
tempTimer(1, [[echo("Time on stopwatch: "..getStopWatchTime(teststopwatch))]])
+
}
tempTimer(2, [[echo("Time on stopwatch: "..getStopWatchTime(teststopwatch))]])
+
 
stopStopWatch(teststopwatch)
+
deleteMapLabel(43, 0)
 +
display(getMapLabels(43))
 +
table {
 +
  1: 'Waterways'
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getStopWatchBrokenDownTime==
+
==getMapMenus==
; brokenDownTimeTable = getStopWatchBrokenDownTime(watchID or watchName)
+
;getMapMenus()
: Returns the current stopwatch time, whether the stopwatch is running or is stopped, as a table, broken down into:
 
* "days" (integer)
 
* "hours" (integer, 0 to 23)
 
* "minutes" (integer, 0 to 59)
 
* "seconds" (integer, 0 to 59)
 
* "milliSeconds" (integer, 0 to 999)
 
* "negative" (boolean, true if value is less than zero)
 
  
: See also: [[Manual:Lua_Functions#startStopWatch|startStopWatch()]], [[Manual:Lua_Functions#stopStopWatch|stopStopWatch()]], [[Manual:Lua_Functions#deleteStopWatch|deleteStopWatch()]], [[Manual:Lua_Functions#getStopWatch es|getStopWatches()]], [[Manual:Lua_Functions#getStopWatchTime|getStopWatchTime()]].
+
: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.
  
;Parameters
+
: See also: [[#addMapMenu|addMapMenu()]], [[#addMapEvent|addMapEvent()]]
* ''watchID'' / ''watchName''
 
: The ID number or the name of the watch.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--an example, showing the presetting of a stopwatch.
+
-- given the following menu structure:
 +
top-level
 +
  menu1
 +
    menu1.1
 +
      action1.1.1
 +
    menu1.2
 +
      action1.2.1
 +
  menu2
  
--This will fail if the stopwatch with the given name
+
getMapMenus() -- will return:
-- already exists, but then we can use the existing one:
+
{
local watchId = createStopWatch("TopMudSiteVoteStopWatch")
+
  menu2 = "top-level",
if watchId ~= nil then
+
   menu1.2 = "menu1",
  -- so we have just created the stopwatch, we want it
+
   menu1.1 = "menu1",
   -- to be saved for future sessions:
+
   menu1 = "top-level"
  setStopWatchPersistence("TopMudSiteVoteStopWatch", true)
+
}
   -- and set it to count down the 12 hours until we can
+
</syntaxhighlight>
  -- revote:
 
  adjustStopWatch("TopMudSiteVoteStopWatch", -60*60*12)
 
   -- and start it running
 
  startStopWatch("TopMudSiteVoteStopWatch")
 
  
  openWebPage("http://www.topmudsites.com/vote-wotmud.html")
+
==getMapSelection==
end
+
; getMapSelection()
 +
 
 +
:Returns a table containing details of the current mouse selection in the 2D mapper.
  
--[[ now I can check when it is time to vote again, even when
+
:Reports on one or more rooms being selected (i.e. they are highlighted in orange).
I stop the session and restart later by running the following
 
from a perm timer - perhaps on a 15 minute interval. Note that
 
when loaded in a new session the Id it gets is unlikely to be
 
the same as that when it was created - but that is not a
 
problem as the name is preserved and, if the timer is running
 
when the profile is saved at the end of the session then the
 
elapsed time will continue to increase to reflect the real-life
 
passage of time:]]
 
  
local voteTimeTable = getStopWatchBrokenDownTime("TopMudSiteVoteStopWatch")
+
: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.
  
if voteTimeTable["negative"] then
+
; Example - several rooms selected
   if voteTimeTable["hours"] == 0 and voteTimeTable["minutes"] < 30 then
+
<syntaxhighlight lang="lua">
     echo("Voting for WotMUD on Top Mud Site in " .. voteTimeTable["minutes"] .. " minutes...")
+
display(getMapSelection())
  end
+
{
else
+
   center = 5013,
  echo("Oooh, it is " .. voteTimeTable["days"] .. " days, " .. voteTimeTable["hours"] .. " hours and " .. voteTimeTable["minutes"] .. " minutes past the time to Vote on Top Mud Site - doing it now!")
+
  rooms = {
   openWebPage("http://www.topmudsites.com/vote-wotmud.html")
+
    5011,
  resetStopWatch("TopMudSiteVoteStopWatch")
+
     5012,
  adjustStopWatch("TopMudSiteVoteStopWatch", -60*60*12)
+
    5013,
end
+
    5014,
 +
    5018,
 +
    5019,
 +
    5020
 +
  }
 +
}
 +
</syntaxhighlight>
 +
; Example - one room selected
 +
<syntaxhighlight lang="lua">
 +
display(getMapSelection())
 +
{
 +
   center = 5013,
 +
  rooms = {
 +
    5013
 +
  }
 +
}
 +
</syntaxhighlight>
 +
; Example - no or something other than a room selected
 +
<syntaxhighlight lang="lua">
 +
display(getMapSelection())
 +
{
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|4.7}}
+
{{MudletVersion|3.17}}
  
==getScript==
+
==getMapUserData==
; getScript(scriptName, [occurrence])
+
;getMapUserData( key )
: Returns the script with the given name. If you have more than one script with the same name, specify the occurrence to pick a different one. Returns -1 if the script doesn't exist.
 
  
: See also: [[Manual:Lua_Functions#permScript|permScript()]], [[Manual:Lua_Functions#enableScript|enableScript()]], [[Manual:Lua_Functions#disableScript|disableScript()]], [[Manual:Lua_Functions#setScript|setScript()]], [[Manual:Lua_Functions#appendScript|appendScript()]]
+
;Parameters
 +
* ''key:''
 +
: string used as a key to select the data stored in the map as a whole.
  
;Parameters
+
: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.
* ''scriptName'': name of the script.
+
 
* ''occurrence'': (optional) occurence of the script in case you have many with the same name.
+
: See also: [[#getAllMapUserData|getAllMapUserData()]], [[#setMapUserData|setMapUserData()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- show the "New script" on screen
+
display(getMapUserData("last updated"))
print(getScript("New script"))
+
--might result in:--
 +
"December 5, 2020"
 +
</syntaxhighlight>
  
-- an example of returning the script Lua code from the second occurrence of "testscript"
+
{{MudletVersion|3.0}}
test_script_code = getScript("testscript", 2)
+
 
</syntaxhighlight>
+
==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.
  
{{MudletVersion|4.8}}
+
:See also: [[Manual:Mapper_Functions#setMapZoom|setMapZoom()]].
  
==invokeFileDialog==
+
{{MudletVersion| 4.17.0}}
;invokeFileDialog(fileOrFolder, dialogTitle)
 
:Opens a file chooser dialog, allowing the user to select a file or a folder visually. The function returns the selected path or "" if there was none chosen.
 
  
 
;Parameters
 
;Parameters
* ''fileOrFolder:'' ''true'' for file selection, ''false'' for folder selection.
+
* ''areaID:''
* ''dialogTitle'': what to say in the window title.
+
: 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.
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function whereisit()
+
echo("\nCurrent zoom level: " .. getMapZoom() .. "\n")
  local path = invokeFileDialog(false, "Where should we save the file? Select a folder and click Open")
+
-- Could be anything from 3 upwards:
  
  if path == "" then return nil else return path end
+
Current zoom level: 42.4242
end
+
 
 +
setMapZoom(2.5 + getMapZoom(1), 1) -- zoom out the area with ID 1 by 2.5
 +
true
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==isActive==
+
{{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''.
  
;isActive(name/IDnumber, type[, checkAncestors])
+
==getPath==
:You can use this function to check if something, or somethings, are active.
+
;getPath(roomID from, roomID to)
  
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
+
: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.
  
;Parameters
 
* ''name:''
 
:The name (as a string) or, from '''Mudlet 4.17.0''', the ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 
* ''type:''
 
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').
 
* ''checkAncestors:''
 
:(Optional) If provided AND ''true'' (considered ''false'' if absent to reproduce behavior of previous versions of Mudlet) then this function will only count an item as active if it '''and''' all its parents (ancestors) are active (from '''Mudlet tbd''').
 
  
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]
+
: See also: [[Manual:Lua_Functions#translateTable|translateTable()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")
+
-- check if we can go to room 155 from room 34 - if yes, go to it
 
+
if getPath(34,155) then
-- Can also be used to check if a specific item is enabled or not.
+
   gotoRoom(155)
if isActive("spellname", "trigger") > 0 then
 
   -- the spellname trigger is active
 
 
else
 
else
   -- it is not active
+
   echo("\nCan't go there!")
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} A positive ID number that does not exist will still return a ''0'' value, this is for constancy with the way the function behaves for a name that does not refer to any item either. If necessary the existence of an item should be confirmed with [[#exists|exists(...)]] first.
+
==getPlayerRoom==
 +
;getPlayerRoom()
 +
 
 +
:Returns the current player location as set by [[#centerview|centerview()]].
  
==isAncestorsActive==
+
: See also: [[#centerview|centerview]]
  
;isAncestorsActive(IDnumber, "type")
+
;Example
:You can use this function to check if '''all''' the ancestors of something are active independent of whether it itself is, (for that use the two argument form of [[#isActive|isActive(...)]]).
+
<syntaxhighlight lang="lua">
 +
display("We're currently in " .. getRoomName(getPlayerRoom()))
 +
</syntaxhighlight>
  
:Returns ''true'' if all (if any) of the ancestors of the item with the specified ID number and type are active, if there are no such parents then it will also returns ''true''; otherwise returns ''false''. In the event that an invalid type string or item number is provided returns ''nil'' and an error message.
+
{{MudletVersion|3.14}}
  
;Parameters
+
==getRoomArea==
* ''IDnumber:''
+
;getRoomArea(roomID)
:The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
+
 
* ''type:''
+
: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.
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
 
  
:See also: [[#exists|exists(...)]]
+
{{note}} If the room ID does not exist, this function will raise an error.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- To do
+
display("Area ID of room #100 is: "..getRoomArea(100))
 +
 
 +
display("Area name for room #100 is: "..getRoomAreaName(getRoomArea(100)))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==isPrompt==
+
==getRoomAreaName==
;isPrompt()
+
;getRoomAreaName(areaID or areaName)
:Returns true or false depending on if the line at the cursor position is a prompt. This infallible feature is available for games that supply GA events (to check if yours is one, look to bottom-right of the main window - if it doesn’t say <No GA>, then it supplies them).
 
  
:Example use could be as a Lua function, making closing gates on a prompt real easy.
+
:Returns the area name for a given area id; or the area id for a given area name.
 +
 
 +
{{note}} Despite the name, this function will not return the area name for a given ''room'' id (or room name) directly. However, renaming or revising it would break existing scripts.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- make a trigger pattern with 'Lua function', and this will trigger on every prompt!
+
echo(string.format("room id #455 is in %s.", getRoomAreaName(getRoomArea(455))))
-- note that this is deprecated as we now have the prompt trigger type which does the same thing
 
-- the function can still be useful for detecting if you're running code on a prompt for other reasons
 
-- but you should be using a prompt trigger for this rather than a Lua function trigger.
 
return isPrompt()
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==killAlias==
+
 
;killAlias(aliasID)
+
==getRoomChar==
:Deletes a temporary alias with the given ID.
+
;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
 
;Parameters
* ''aliasID:''
+
* ''roomID:''
: The id returned by [[Manual:Lua_Functions#tempAlias|tempAlias]] to identify the alias.
+
: 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
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- deletes the alias with ID 5
+
-- gets the color of the room character set on room 12345. If no room character is set the default 'color' is 0,0,0
killAlias(5)
+
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>.\")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==killKey==
+
==getRoomCoordinates==
;killKey(name)
+
;x,y,z = getRoomCoordinates(roomID)
:Deletes a keybinding with the given name. If several keybindings have this name, they'll all be deleted.
 
  
;Parameters
+
:Returns the room coordinates of the given room ID.
* ''name:''
 
: The name or the id returned by [[Manual:Lua_Functions#tempKey|tempKey]] to identify the key.
 
  
{{MudletVersion|3.2}}
+
;Example
 +
<syntaxhighlight lang="lua">
 +
local x,y,z = getRoomCoordinates(roomID)
 +
echo("Room Coordinates for "..roomID..":")
 +
echo("\n    X:"..x)
 +
echo("\n    Y:"..y)
 +
echo("\n    Z:"..z)
 +
</syntaxhighlight>
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- make a temp key
+
-- 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.
local keyid = tempKey(mudlet.key.F8, [[echo("hi!")]])
+
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
 +
</syntaxhighlight>
  
-- delete the said temp key
+
==getRoomEnv==
killKey(keyid)
+
;envID = getRoomEnv(roomID)
</syntaxhighlight>
 
  
==killTimer==
+
: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.
;killTimer(id)
 
:Deletes a [[Manual:Lua_Functions#tempTimer|tempTimer]].
 
  
{{note}} Non-temporary timers that you have set up in the GUI or by using [[#permTimer|permTimer]] cannot be deleted with this function. Use [[Manual:Lua_Functions#disableTimer|disableTimer()]] and [[Manual:Lua_Functions#enableTimer|enableTimer()]] to turn them on or off.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
function checkID(id)
 +
  echo(string.format("The env ID of room #%d is %d.\n", id, getRoomEnv(id)))
 +
end
 +
</syntaxhighlight>
  
;Parameters
+
== getRoomExits ==
* ''id:'' the ID returned by [[Manual:Lua_Functions#tempTimer|tempTimer]].
+
;getRoomExits (roomID)
 +
:Returns the currently known non-special exits for a room in an key-index form: ''exit = exitroomid''.
  
: Returns true on success and false if the timer id doesn’t exist anymore (timer has already fired) or the timer is not a temp timer.
+
: See also: [[#getSpecialExits|getSpecialExits()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create the timer and remember the timer ID
+
table {
timerID = tempTimer(10, [[echo("hello!")]])
+
  'northwest': 80
 +
  'east': 78
 +
}
 +
</syntaxhighlight>
  
-- delete the timer
+
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):
killTimer(timerID)
 
-- reset the reference to it
 
timerID = nil
 
</syntaxhighlight>
 
  
==killTrigger==
+
<syntaxhighlight lang="lua">
;killTrigger(id)
+
local exits = getRoomExits(mycurrentroomid)
:Deletes a [[Manual:Lua_Functions#tempTimer|tempTrigger]], or a trigger made with one of the ''temp<type>Trigger()'' functions.
+
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>
  
{{note}} When used in out of trigger contexts, the triggers are disabled and deleted upon the next line received from the game - so if you are testing trigger deletion within an alias, the 'statistics' window will be reporting trigger counts that are disabled and pending removal, and thus are no cause for concern.
+
==getRoomHashByID==
 +
;getRoomHashByID(roomID)
  
;Parameters
+
: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.
* ''id:''
 
: The ID returned by a ''temp<type>Trigger'' to identify the item. ID is a string and not a number.
 
  
:Returns true on success and false if the trigger id doesn’t exist anymore (trigger has already fired) or the trigger is not a temp trigger.
+
: See also: [[#getRoomIDbyHash|getRoomIDbyHash()]]
 +
{{MudletVersion|3.13.0}}
  
{{note}} As of Mudlet version 4.16.0, triggers created with [[#tempComplexRegexTrigger|tempComplexRegexTrigger]] can only be killed using the name string specified during creation.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
    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>
  
==permAlias==
+
==getRoomIDbyHash==
;permAlias(name, parent, regex, lua code)
+
;roomID = getRoomIDbyHash(hash)
  
:Creates a persistent alias that stays after Mudlet is restarted and shows up in the Script Editor.
+
:Returns a room ID that is associated with a given hash in the mapper. This is primarily for games that make use of hashes instead of room IDs (like [http://avalon.mud.de/index.php?enter=1 Avalon.de]). ''-1'' is returned if no room ID matches the hash.
 +
 
 +
: See also: [[#getRoomHashByID|getRoomHashByID()]]
  
;Parameters
 
* ''name:''
 
: The name you’d like the alias to have.
 
* ''parent:''
 
: The name of the group, or another alias you want the trigger to go in - however if such a group/alias doesn’t exist, it won’t do anything. Use "" to make it not go into any groups.
 
* ''regex:''
 
: The pattern that you’d like the alias to use.
 
* ''lua code:''
 
: The script the alias will do when it matches.
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- creates an alias called "new alias" in a group called "my group"
+
-- example taken from http://forums.mudlet.org/viewtopic.php?f=13&t=2177
permAlias("new alias", "my group", "^test$", [[echo ("say it works! This alias will show up in the script editor too.")]])
+
local id = getRoomIDbyHash("5dfe55b0c8d769e865fd85ba63127fbc")
 +
if id == -1 then
 +
  id = createRoomID()
 +
  setRoomIDbyHash(id, "5dfe55b0c8d769e865fd85ba63127fbc")
 +
  addRoom(id)
 +
  setRoomCoordinates(id, 0, 0, -1)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} Mudlet by design allows duplicate names - so calling permAlias with the same name will keep creating new aliases. You can check if an alias already exists with the [[Manual:Lua_Functions#exists|exists]] function.
+
==getRoomName==
 +
;getRoomName(roomID)
  
==permGroup==
+
:Returns the room name for a given room id.
;permGroup(name, itemtype, [parent])
 
  
:Creates a new group of a given type. This group will persist through Mudlet restarts.
+
;Example
;Parameters
+
<syntaxhighlight lang="lua">
* ''name'':
+
echo(string.format("The name of the room id #455 is %s.", getRoomName(455))
: The name of the new group item you want to create.
+
</syntaxhighlight>
* ''itemtype'' :
+
 
: The type of the item, can be one of the following:
+
==getRooms==
:: trigger
+
;rooms = getRooms()
:: alias
+
 
:: timer
+
:Returns the list of '''all''' rooms in the map in the whole map in roomid - room name format.
:: script (available in Mudlet 4.7+)
 
:: key (available in Mudlet 4.11+)
 
* ''parent'' (available in Mudlet 3.1+):
 
: (optional) Name of existing item which the new item will be created as a child of. If none is given, item will be at the root level (not nested in any other groups)
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--create a new trigger group
+
-- simple, raw viewer for rooms in the world
permGroup("Combat triggers", "trigger")
+
display(getRooms())
  
--create a new alias group only if one doesn't exist already
+
-- iterate over all rooms in code
if exists("Defensive aliases", "alias") == 0 then
+
for id,name in pairs(getRooms()) do
   permGroup("Defensive aliases", "alias")
+
   print(id, name)
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==permPromptTrigger==
+
==getRoomsByPosition==
;permPromptTrigger(name, parent, lua code)
+
;roomTable = getRoomsByPosition(areaID, x,y,z)
:Creates a persistent trigger for the in-game prompt that stays after Mudlet is restarted and shows up in the Script Editor.
 
  
{{note}} If the trigger is not working, check that the '''N:''' bottom-right has a number. This feature requires telnet Go-Ahead (GA) or End-of-Record (EOR) to be enabled in your game. Available in Mudlet 3.6+
+
: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.
  
;Parameters:
+
{{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.
* ''name'' is the name you’d like the trigger to have.
 
* ''parent'' is the name of the group, or another trigger you want the trigger to go in - however if such a group/trigger doesn’t exist, it won’t do anything. Use "" to make it not go into any groups.
 
* ''lua code'' is the script the trigger will do when it matches.
 
  
;Example:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
permPromptTrigger("echo on prompt", "", [[echo("hey! this thing is working!\n")]])
+
-- 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
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
==getRoomUserData==
 +
;getRoomUserData(roomID, key)
  
==permRegexTrigger==
+
: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.
;permRegexTrigger(name, parent, pattern table, lua code)
 
:Creates a persistent trigger with one or more ''regex'' patterns that stays after Mudlet is restarted and shows up in the Script Editor.
 
  
;Parameters
 
* ''name'' is the name you’d like the trigger to have.
 
* ''parent'' is the name of the group, or another trigger you want the trigger to go in - however if such a group/trigger doesn’t exist, it won’t do anything. Use "" to make it not go into any groups.
 
* ''pattern table'' is a table of patterns that you’d like the trigger to use - it can be one or many.
 
* ''lua code'' is the script the trigger will do when it matches.
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Create a regex trigger that will match on the prompt to record your status
+
display(getRoomUserData(341, "visitcount"))
permRegexTrigger("Prompt", "", {"^(\d+)h, (\d+)m"}, [[health = tonumber(matches[2]); mana = tonumber(matches[3])]])
 
 
</syntaxhighlight>
 
</syntaxhighlight>
{{note}} Mudlet by design allows duplicate names - so calling permRegexTrigger with the same name will keep creating new triggers. You can check if a trigger already exists with the [[Manual:Lua_Functions#exists|exists()]] function.
 
  
==permBeginOfLineStringTrigger==
+
:;getRoomUserData(roomID, key, enableFullErrorReporting)
;permBeginOfLineStringTrigger(name, parent, pattern table, lua code)
 
:Creates a persistent trigger that stays after Mudlet is restarted and shows up in the Script Editor. The trigger will go off whenever one of the ''regex'' patterns it's provided with matches. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls.
 
  
;Parameters
+
::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.
* ''name'' is the name you’d like the trigger to have.
+
 
* ''parent'' is the name of the group, or another trigger you want the trigger to go in - however if such a group/trigger doesn’t exist, it won’t do anything. Use "" to make it not go into any groups.
+
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
* ''pattern table'' is a table of patterns that you’d like the trigger to use - it can be one or many.
+
 
* ''lua code'' is the script the trigger will do when it matches.
+
;Example
 +
<!-- I would like this block to be indented to match the Example header but the mark-up system seems to be broken and only includes the first line
 +
if the start of the code line begins: ":<lua>..."-->
 +
<syntaxhighlight lang="lua">local vNum = 341
 +
result, errMsg = getRoomUserData(vNum, "visitcount", true)
 +
if result ~= nil then
 +
    display(result)
 +
else
 +
    echo("\nNo visitcount data for room: "..vNum.."; reason: "..errMsg.."\n")
 +
end</syntaxhighlight>
 +
 
 +
==getRoomUserDataKeys==
 +
;getRoomUserDataKeys(roomID)
 +
 
 +
:Returns all the keys for user data items stored in the given room ID; will return an empty table if there is no data stored or nil if there is no such room with that ID. ''Can be useful if the user was not the one who put the data in the map in the first place!''
 +
 
 +
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]], [[#setRoomUserData|setRoomUserData()]]
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Create a trigger that will match on anything that starts with "You sit" and do "stand".
+
display(getRoomUserDataKeys(3441))
-- It will not go into any groups, so it'll be on the top.
+
--might result in:--
permBeginOfLineStringTrigger("Stand up", "", {"You sit"}, [[send ("stand")]])
+
{
 +
  "description",
 +
  "doorname_up",
 +
}
 +
</syntaxhighlight>
  
-- Another example - lets put our trigger into a "General" folder and give it several patterns.
+
{{MudletVersion|3.0}}
permBeginOfLineStringTrigger("Stand up", "General", {"You sit", "You fall", "You are knocked over by"}, [[send ("stand")]])
+
 
 +
==getRoomWeight==
 +
;getRoomWeight(roomID)
 +
 
 +
:Returns the weight of a room. By default, all new rooms have a weight of 1.
 +
: See also: [[#setRoomWeight|setRoomWeight()]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
display("Original weight of room 541: "..getRoomWeight(541))
 +
setRoomWeight(541, 3)
 +
display("New weight of room 541: "..getRoomWeight(541))
 
</syntaxhighlight>
 
</syntaxhighlight>
{{note}} Mudlet by design allows duplicate names - so calling permBeginOfLineStringTrigger with the same name will keep creating new triggers. You can check if a trigger already exists with the [[Manual:Lua_Functions#exists|exists()]] function.
 
  
==permSubstringTrigger==
+
==getSpecialExits==
;permSubstringTrigger( name, parent, pattern table, lua code )
+
;exits = getSpecialExits(roomID[, listAllExits])
:Creates a persistent trigger with one or more ''substring'' patterns that stays after Mudlet is restarted and shows up in the Script Editor.
+
 
 
;Parameters
 
;Parameters
* ''name'' is the name you’d like the trigger to have.
+
* ''roomID:''
* ''parent'' is the name of the group, or another trigger you want the trigger to go in - however if such a group/trigger doesn’t exist, it won’t do anything. Use "" to make it not go into any groups.
+
: Room ID to return the special exits of.
* ''pattern table'' is a table of patterns that you’d like the trigger to use - it can be one or many.
+
* ''listAllExits:''
* ''lua code'' is the script the trigger will do when it matches.
+
: (Since ''TBA'') 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.
 +
: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|getRoomExits()]]
 +
 
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Create a trigger to highlight the word "pixie" for us
+
-- There are three special exits from 1337 to the room 42:
permSubstringTrigger("Highlight stuff", "General", {"pixie"},
+
-- "climb down ladder" which is locked and has an exit weight of 10
[[selectString(line, 1) bg("yellow") resetFormat()]])
+
-- "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"}
 +
}
  
-- Or another trigger to highlight several different things
+
-- From TBA, with the second argument as true, this gives:
permSubstringTrigger("Highlight stuff", "General", {"pixie", "cat", "dog", "rabbit"},
+
getSpecialExits(1337, true)
[[selectString(line, 1) fg ("blue") bg("yellow") resetFormat()]])
+
table {
 +
  42 = {"step out window" = "0",
 +
        "climb down ladder" = "1",
 +
        "jump out window" = "0"},
 +
  666 = {"dive into pit" = "1"}
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
{{note}} Mudlet by design allows duplicate names - so calling permSubstringTrigger with the same name will keep creating new triggers. You can check if a trigger already exists with the [[Manual:Lua_Functions#exists|exists()]] function.
 
  
==permScript==
+
==getSpecialExitsSwap==
;permScript(name, parent, lua code)
+
;getSpecialExitsSwap(roomID)
: Creates a new script in the Script Editor that stays after Mudlet is restarted.
 
  
;Parameters
+
:Very similar to [[#getSpecialExits|getSpecialExits()]] function, but returns the rooms in the command - roomid style.
* ''name'': name of the script.
+
 
* ''parent'': name of the script group you want the script to go in.
+
==gotoRoom==
* ''lua code'': is the code with string you are putting in your script.
+
;gotoRoom (roomID)
 +
:Speedwalks you to the given room from your current room if it is able and knows the way. You must turn the map on for this to work, else it will return "(mapper): Don't know how to get there from here :(".
 +
 
 +
In case this isn't working, and you are coding your own mapping script, [[Manual:Mapper#Making_your_own_mapping_script|see here]] how to implement additional functionality necessary.
  
;Returns
+
==hasExitLock==
* a unique id number for that script.
+
;status = hasExitLock(roomID, direction)
  
: See also: [[#enableScript|enableScript()]], [[#exists|exists()]], [[#appendScript|appendScript()]], [[#disableScript|disableScript()]], [[#getScript|getScript()]], [[#setScript|setScript()]]
+
: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:
+
; Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a script in the "first script group" group
+
-- check if the east exit of room 1201 is locked
permScript("my script", "first script group", [[send ("my script that's in my first script group fired!")]])
+
display(hasExitLock(1201, 4))
-- create a script that's not in any group; just at the top
+
display(hasExitLock(1201, "e"))
permScript("my script", "", [[send ("my script that's in my first script group fired!")]])
+
display(hasExitLock(1201, "east"))
 +
</syntaxhighlight>
  
-- enable Script - a script element is disabled at creation
+
: See also: [[#lockExit|lockExit()]]
enableScript("my script")
 
</syntaxhighlight>
 
  
{{note}} The script is called once but NOT active after creation, it will need to be enabled by [[#enableScript|enableScript()]].
+
==hasSpecialExitLock==
 +
;hasSpecialExitLock(from roomID, to roomID, moveCommand)
  
{{note}} Mudlet by design allows duplicate names - so calling permScript with the same name will keep creating new script elements. You can check if a script already exists with the [[Manual:Lua_Functions#exists|exists()]] function.
+
: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.
  
{{note}} If the ''lua code'' parameter is an empty string, then the function will create a script group instead.
+
See also: [[#lockSpecialExit|lockSpecialExit()]]
  
 +
<syntaxhighlight lang="lua">
 +
-- lock a special exit from 17463 to 7814 that uses the 'enter feather' command
 +
lockSpecialExit(17463, 7814, 'enter feather', true)
  
{{MudletVersion|4.8}}
+
-- see if it is locked: it will say 'true', it is
 +
display(hasSpecialExitLock(17463, 7814, 'enter feather'))
 +
</syntaxhighlight>
  
==permTimer==
+
==highlightRoom==
;permTimer(name, parent, seconds, lua code)
+
;highlightRoom( roomID, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)
: Creates a persistent timer that stays after Mudlet is restarted and shows up in the Script Editor.
+
 
 +
: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
 
;Parameters
* ''name''  
+
* ''roomID''
:name of the timer.
+
: ID of the room to be colored.
* ''parent''  
+
* ''color1Red, color1Green, color1Blue''
:name of the timer group you want the timer to go in.
+
: RGB values of the first color.
* ''seconds''  
+
* ''color2Red, color2Green, color2Blue''
:a floating point number specifying a delay in seconds after which the timer will do the lua code (stored as the timer's "script") you give it as a string.
+
: RGB values of the second color.
* ''lua code'' is the code with string you are doing this to.
+
* ''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).
  
;Returns
+
: See also: [[#unHighlightRoom|unHighlightRoom()]]
* a unique id number for that timer.
 
  
;Example:
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a timer in the "first timer group" group
+
-- color room #351 red to blue
permTimer("my timer", "first timer group", 4.5, [[send ("my timer that's in my first timer group fired!")]])
+
local r,g,b = unpack(color_table.red)
-- create a timer that's not in any group; just at the top
+
local br,bg,bb = unpack(color_table.blue)
permTimer("my timer", "", 4.5, [[send ("my timer that's in my first timer group fired!")]])
+
highlightRoom(351, r,g,b,br,bg,bb, 1, 255, 255)
 
 
-- enable timer - they start off disabled until you're ready
 
enableTimer("my timer")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{note}} The timer is NOT active after creation, it will need to be enabled by a call to [[#enableTimer|enableTimer()]] before it starts.
+
==killMapInfo==
 +
;killMapInfo(label)
  
{{note}} Mudlet by design allows duplicate names - so calling permTimer with the same name will keep creating new timers. You can check if a timer already exists with the [[Manual:Lua_Functions#exists|exists()]] function.
+
Delete a map info contributor entirely - it will be not available anymore.
 
 
==permKey==
 
;permKey(name, parent, [modifier], key code, lua code)
 
: Creates a persistent key that stays after Mudlet is restarted and shows up in the Script Editor.
 
  
 
;Parameters
 
;Parameters
* ''name''
+
* ''label:''
:name of the key.
+
: Name under which map info to be removed was registered.
* ''parent''  
 
:name of the timer group you want the timer to go in or "" for the top level.
 
* ''modifier''
 
:(optional) modifier to use - can be one of ''mudlet.keymodifier.Control'', ''mudlet.keymodifier.Alt'', ''mudlet.keymodifier.Shift'', ''mudlet.keymodifier.Meta'', ''mudlet.keymodifier.Keypad'', or ''mudlet.keymodifier.GroupSwitch'' or the default value of ''mudlet.keymodifier.None'' which is used if the argument is omitted. To use multiple modifiers, add them together: ''(mudlet.keymodifier.Shift + mudlet.keymodifier.Control)''
 
* ''key code''
 
: actual key to use - one of the values available in ''mudlet.key'', e.g. ''mudlet.key.Escape'', ''mudlet.key.Tab'', ''mudlet.key.F1'', ''mudlet.key.A'', and so on. The list is a bit long to list out in full so it is [https://github.com/Mudlet/Mudlet/blob/development/src/mudlet-lua/lua/KeyCodes.lua#L2 available here].
 
: set to -1 if you want to create a key folder instead.
 
* ''lua code'
 
: code you would like the key to run.
 
  
;Returns
+
: See also: [[#registerMapInfo|registerMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#disableMapInfo|disableMapInfo()]]
* a unique id number for that key.
 
  
{{MudletVersion|3.2+, creating key folders in Mudlet 4.10}}
+
{{MudletVersion|4.11}}
  
;Example:
+
==loadJsonMap==
<syntaxhighlight lang="lua">
+
; loadJsonMap(pathFileName)
-- create a key at the top level for F8
 
permKey("my key", "", mudlet.key.F8, [[echo("hey this thing actually works!\n")]])
 
  
-- or Ctrl+F8
+
; Parameters:
permKey("my key", "", mudlet.keymodifier.Control, mudlet.key.F8, [[echo("hey this thing actually works!\n")]])
 
  
-- Ctrl+Shift+W
+
* ''pathFileName'' a string that is an absolute path and file name to read the data from.
permKey("jump keybinding", "", mudlet.keymodifier.Control + mudlet.keymodifier.Shift, mudlet.key.W, [[send("jump")]])
 
</syntaxhighlight>
 
  
{{note}} Mudlet by design allows duplicate names - so calling permKey with the same name will keep creating new keys. You can check if a key already exists with the [[Manual:Lua_Functions#exists|exists()]] function. The key will be created even if the lua code does not compile correctly - but this will be apparent as it will be seen in the Editor.
+
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.
  
==printCmdLine==
+
: See also: [[#saveJsonMap|saveJsonMap()]]
;printCmdLine([name], text)
 
  
: Replaces the current text in the input line, and sets it to the given text.
+
Returns:
: See also: [[Manual:Lua_Functions#clearCmdLine|clearCmdLine()]], [[#appendCmdLine|appendCmdLine()]]
+
* ''true'' on success
 +
* ''nil'' and an error message on failure.
  
;Parameters
+
;Example
* ''name'': (optional) name of the command line. If not given, main commandline's text will be set.
+
<syntaxhighlight lang="lua">
* ''text'': text to set
+
loadJsonMap(getMudletHomeDir() .. "/map.json")
  
<syntaxhighlight lang="lua">
+
true
printCmdLine("say I'd like to buy ")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==raiseEvent==
+
{{MudletVersion|4.11.0}}
;raiseEvent(event_name, arg-1, … arg-n)
 
  
: Raises the event event_name. The event system will call the main function (the one that is called exactly like the script name) of all such scripts in this profile that have registered event handlers. If an event is raised, but no event handler scripts have been registered with the event system, the event is ignored and nothing happens. This is convenient as you can raise events in your triggers, timers, scripts etc. without having to care if the actual event handling has been implemented yet - or more specifically how it is implemented. Your triggers raise an event to tell the system that they have detected a certain condition to be true or that a certain event has happened. How - and if - the system is going to respond to this event is up to the system and your trigger scripts don’t have to care about such details. For small systems it will be more convenient to use regular function calls instead of events, however, the more complicated your system will get, the more important events will become because they help reduce complexity very much.
+
==loadMap==
 +
;loadMap(file location)
  
:The corresponding event handlers that listen to the events raised with raiseEvent() need to use the script name as function name and take the correct number of arguments.  
+
: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.  
  
:See also: [[#raiseGlobalEvent|raiseGlobalEvent]]
+
: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.
 +
 
 +
<syntaxhighlight lang="lua">
 +
  loadMap("/home/user/Desktop/Mudlet Map.dat")
 +
</syntaxhighlight>
  
{{note}} possible arguments can be string, number, boolean, table, function, or nil.
+
{{Note}} A file name ending with <code>.xml</code> will indicate the XML format.
  
;Example:
+
==lockExit==
 +
;lockExit(roomID, direction, lockIfTrue)
  
:raiseEvent("fight") a correct event handler function would be: myScript( event_name ). In this example raiseEvent uses minimal arguments, name the event name. There can only be one event handler function per script, but a script can still handle multiple events as the first argument is always the event name - so you can call your own special handlers for individual events. The reason behind this is that you should rather use many individual scripts instead of one huge script that has all your function code etc. Scripts can be organized very well in trees and thus help reduce complexity on large systems.
+
: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").
  
Where the number of arguments that your event may receive is not fixed you can use [http://www.lua.org/manual/5.1/manual.html#2.5.9 ''...''] as the last argument in the ''function'' declaration to handle any number of arguments. For example:
+
: See also: [[#hasExitLock|hasExitLock()]]
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- try this function out with "lua myscripthandler(1,2,3,4)"
+
-- lock the east exit of room 1201 so we never path through it
function myscripthandler(a, b, ...)
+
lockExit(1201, 4, true)
  print("Arguments a and b are: ", a,b)
 
  -- save the rest of the arguments into a table
 
  local otherarguments = {...}
 
  print("Rest of the arguments are:")
 
  display(otherarguments)
 
 
 
  -- access specific otherarguments:
 
  print("First and second otherarguments are: ", otherarguments[1], otherarguments[2])
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==raiseGlobalEvent==
+
==lockRoom==
;raiseGlobalEvent(event_name, arg-1, … arg-n)
+
;lockRoom (roomID, lockIfTrue)
  
: Like [[Manual:Lua_Functions#raiseEvent|raiseEvent()]] this raises the event "event_name", but this event is sent to all '''other''' opened profiles instead. The profiles receive the event in circular alphabetical order (if profile "C" raised this event and we have profiles "A", "C", and "E", the order is "E" -> "A", but if "E" raised the event the order would be "A" -> "C"); execution control is handed to the receiving profiles so that means that long running events may lock up the profile that raised the event.
+
:Locks a given room id from future speed walks (thus the mapper will never path through that room).
 +
: See also: [[#roomLocked | roomLocked()]]
  
: The sending profile's name is automatically appended as the last argument to the event.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
lockRoom(1, true) -- locks a room if from being walked through when speedwalking.
 +
lockRoom(1, false) -- unlocks the room, adding it back to possible rooms that can be walked through.
 +
</syntaxhighlight>
  
{{note}} possible arguments can be string, number, boolean, or nil, but not table or function.
+
==lockSpecialExit==
 +
;lockSpecialExit (from roomID, to roomID, special exit command, lockIfTrue)
  
;Example:
+
:Locks a given special exit, leading from one specific room to another that uses a certain command from future speed walks (thus the mapper will never path through that special exit).
 +
: See also: [[#hasSpecialExitLock | hasSpecialExitLock()]], [[#lockExit | lockExit()]], [[#lockRoom | lockRoom()]]
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- from profile called "My game" this raises an event "my event" with additional arguments 1, 2, 3, "My game" to all profiles except the original one
+
lockSpecialExit(1,2,'enter gate', true) -- locks the special exit that does 'enter gate' to get from room 1 to room 2
raiseGlobalEvent("my event", 1, 2, 3)
+
lockSpecialExit(1,2,'enter gate', false) -- unlocks the said exit
 
 
-- want the current profile to receive it as well? Use raiseEvent
 
raiseEvent("my event", 1, 2, 3)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<syntaxhighlight lang="lua>
+
==mapSymbolFontInfo==
-- example of calling functions in one profile from another:
 
-- profile B:
 
control = control or {}
 
function control.updateStatus()
 
  disableTrigger("test triggers")
 
  print("disabling triggers worked!")
 
end
 
  
-- this handles calling the right function in the control table
+
;mapSymbolFontInfo()
function control.marshaller(_, callfunction)
+
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
  if control[callfunction] then control[callfunction]()
 
  else
 
    cecho("<red>Asked to call an unknown function: "..callfunction)
 
  end
 
end
 
  
registerAnonymousEventHandler("sysSendAllProfiles", "control.marshaller")
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
  
-- profile A:
+
;returns
raiseGlobalEvent("sysSendAllProfiles", "updateStatus")
+
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:
raiseGlobalEvent("sysSendAllProfiles", "invalidfunction")
+
:* ''fontName'' - a string of the family name of the font specified
</syntaxhighlight>
+
:* ''onlyUseThisFont'' - a boolean indicating whether glyphs from just the ''fontName'' font are to be used or if there is not a ''glyph'' for the required ''grapheme'' (''character'') then a ''glyph'' from the most suitable different font will be substituted instead. Should this be ''true'' and the specified font does not have the required glyph then the replacement character (typically something like ''�'') could be used instead. Note that this may not affect the use of Color Emoji glyphs that are automatically used in some OSes but that behavior does vary across the range of operating systems that Mudlet can be run on.
 +
:* ''scalingFactor'' - a floating point number between 0.50 and 2.00 which modifies the size of the symbols somewhat though the extremes are likely to be unsatisfactory because some of the particular symbols may be too small (and be less visible at smaller zoom levels) or too large (and be clipped by the edges of the room rectangle or circle).
 +
* or ''nil'' and an error message on failure.
  
{{MudletVersion|3.1.0}}
+
::As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialized, by activating a map window).
  
Tip: you might want to add the [[Manual:Miscellaneous_Functions#getProfileName|profile name]] to your plain [[Manual:Miscellaneous_Functions#raiseEvent|raiseEvent()]] arguments. This'll help you tell which profile your event came from similar to [[#raiseGlobalEvent|raiseGlobalEvent()]].
+
==moveMapLabel==
  
==registerNamedTimer==
+
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
; success = registerNamedTimer(userName, timerName, time, functionReference, [repeating])
+
Re-positions a map label within an area in the 2D mapper, in a similar manner as the [[#moveRoom|moveRoom()]] function does for rooms and their custom exit lines. When moving a label to given coordinates this is the position that the top-left corner of the label will be positioned at; since the space allocated to a particular room on the map is ± 0.5 around the integer value of its x and y coordinates this means for a label which has a size of 1.0 x 1,0 (w x h) to position it centrally in the space for a single room at the coordinates (x, y, z) it should be positioned at (x - 0.5, y + 0.5, z).
  
:Registers a named timer with name timerName. Named timers are protected from duplication and can be stopped and resumed, unlike normal tempTimers. A separate list is kept for each userName, to enforce name spacing and avoid collisions
+
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].
  
;See also: [[Manual:Lua_Functions#tempTimer|tempTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]], [[Manual:Lua_Functions#resumeNamedTimer|resumeNamedTimer()]], [[Manual:Lua_Functions#deleteNamedTimer|deleteNamedTimer()]], [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]]
+
{{MudletVersion| ?.??}}
  
{{MudletVersion|4.14}}
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
  
 
;Parameters
 
;Parameters
* ''userName:''
+
* ''areaID/Name:''
: The user name the event handler was registered under.
+
: Area ID as number or AreaName as string containing the map label.
* ''timerName:''
 
: The name of the handler. Used to reference the handler in other functions and prevent duplicates. Recommended you use descriptive names, "hp" is likely to collide with something else, "DemonVitals" less so.
 
* ''time:''
 
: The amount of time in seconds to wait before firing.
 
* ''functionReference:''
 
: The function reference to run when the event comes in. Can be the name of a function, "handlerFunction", or the lua function itself.
 
* ''repeating:''
 
: (optional) if true, the timer continue to fire until the stop it using [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
 
;Returns
 
* true if successful, otherwise errors.
 
  
;Example
+
* ''labelID/Text:''
<syntaxhighlight lang="lua">
+
: Label ID as number (which will be 0 or greater) or the LabelText on a text label. All labels will have a unique ID number but there may be more than one ''text'' labels with a non-empty text string; only the first matching one will be moved by this function and image labels also have no text and will match the empty string.  with mo or AreaName as string containing the map label.
-- establish a named timer called "Check balance" which runs balanceChecker() after 1 second
 
-- it is started automatically when registered, and fires only once despite being run twice
 
-- you wouldn't do this intentionally, but illustrates the duplicate protection
 
registerNamedTimer("Demonnic", "Check Balance", 1, balanceChecker)
 
registerNamedTimer("Demonnic", "Check Balance", 1, balanceChecker)
 
  
-- then the next time you want to make/use the same timer, you can shortcut it with
+
* ''coordX/deltaX:''
resumeNamedTimer("Demonnic", "Check Balance")
+
: A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the X-axis.
</syntaxhighlight>
 
  
==remainingTime==
+
* ''coordY/deltaY:''
;remainingTime(timer id number or name)
+
: A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Y-axis.
  
: Returns the remaining time in floating point form in seconds (if it is active) for the timer (temporary or permanent) with the id number or the (first) one found with the name.
+
* ''coordZ/deltaZ:''
: If the timer is inactive or has expired or is not found it will return a ''nil'' and an ''error message''. It, theoretically could also return 0 if the timer is overdue, i.e. it has expired but the internal code has not yet been run but that has not been seen in during testing. Permanent ''offset timers'' will only show as active during the period when they are running after their parent has expired and started them.
+
: (Optional) A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Z-axis, if omitted the label is not moved in the z-axis at all.
  
{{MudletVersion|3.20}}
+
* ''absoluteNotRelativeMove:''
 +
: (Optional) a boolean value (defaults to ''false'' if omitted) as to whether to move the label to the absolute coordinates (''true'') or to move it the relative amount from its current location (''false'').
  
;Example:
+
;Returns
 +
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
tid = tempTimer(600, [[echo("\nYour ten minutes are up.\n")]])
+
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
echo("\nYou have " .. remainingTime(tid) .. " seconds left, use it wisely... \n")
+
moveMapLabel(0, 2, 3.0, 4.0)
  
-- Will produce something like:
+
-- move the first label in the area with the ID number of 2, one space to the west, note the final boolean argument is unneeded
 +
moveMapLabel(0, 2, -1.0, 0.0, false)
  
You have 599.923 seconds left, use it wisely...  
+
-- move the second label in the area with the ID number of 2, three and a half spaces to the west, and two south **of the center of the current level it is on in the map**:
 +
moveRoom(1, 2, -3.5, -2.0, true)
  
-- Then ten minutes time later:
+
-- move the second label in the area with the ID number of 2, up three levels
 +
moveRoom(1, 2, 0.0, 0.0, 3.0)
  
Your ten minutes are up.
+
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded
 +
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
  
 +
-- move the (top-left corner of the first) label with the text "Home" in the area with ID number 5 to the **center of the whole map**, note the last two arguments are required in this case:
 +
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)
 +
 +
-- all of the above will return the 'true'  boolean value assuming there are the indicated labels and areas
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==resetProfileIcon==
+
==moveMapWidget==
;resetProfileIcon()
+
;moveMapWidget(Xpos, Ypos)
: Resets the profile's icon in the connection screen to default.
+
:moves the map window to the given position.
 +
: See also: [[#openMapWidget|openMapWidget()]], [[#closeMapWidget|closeMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
  
See also: [[#setProfileIcon|setProfileIcon()]].
+
;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.0}}
+
{{MudletVersion|4.7}}
  
;Example:
+
==openMapWidget==
 +
;openMapWidget([dockingArea | Xpos, Ypos, width, height])
 +
means either of these are fine:
 +
;openMapWidget()
 +
;openMapWidget(dockingArea)
 +
;openMapWidget(Xpos, Ypos, width, height)
  
<syntaxhighlight lang="lua">
+
:opens a map window with given options.
resetProfileIcon()
 
</syntaxhighlight>
 
  
==resetStopWatch==
+
: See also: [[#closeMapWidget|closeMapWidget()]], [[#moveMapWidget|moveMapWidget()]], [[#resizeMapWidget|resizeMapWidget()]]
;resetStopWatch(watchID)
 
:This function resets the time to 0:0:0.0, but does not stop or start the stop watch. You can stop it with [[Manual:Lua_Functions#stopStopWatch | stopStopWatch]] or start it with [[Manual:Lua_Functions#startStopWatch | startStopWatch]] [[Manual:Lua_Functions#createStopWatch | createStopWatch]]
 
  
==resumeNamedTimer==
+
{{MudletVersion|4.7}}
; success = resumeNamedTimer(userName, handlerName)
 
  
:Resumes a named timer with name handlerName and causes it to fire again. One time unless it was registered as repeating.
+
;Parameters
 +
{{note}} If no parameter is given the map window will be opened with the saved layout or at the right docking position (similar to clicking the icon)
 +
* ''dockingArea:''
 +
: If only one parameter is given this parameter will be a string that contains one of the possible docking areas the map window will be created in (f" floating "t" top "b" bottom "r" right and "l" left)
 +
{{note}} If 4 parameters are given the map window will be created in floating state
 +
* ''Xpos:''
 +
: X position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
 +
* ''Ypos:''
 +
: Y position of the map window. Measured in pixels, with 0 being the very left. Passed as an integer number.
 +
* ''width:''
 +
: The width map window, in pixels. Passed as an integer number.
 +
* ''height:''
 +
: The height map window, in pixels. Passed as an integer number.
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
+
==pauseSpeedwalk==
 +
;pauseSpeedwalk()
  
{{MudletVersion|4.14}}
+
:Pauses a speedwalk started using [[#speedwalk|speedwalk()]]
  
;Parameter
+
: See also: [[#speedwalk|speedwalk()]], [[#stopSpeedwalk|stopSpeedwalk()]], [[#resumeSpeedwalk|resumeSpeedwalk()]]
* ''userName:''
 
: The user name the event handler was registered under.s
 
* ''handlerName:''
 
: The name of the handler to resume. Same as used when you called [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
 
  
;Returns
+
{{MudletVersion|4.13}}
* true if successful, false if it didn't exist. If the timer is waiting to fire it will be restarted at 0.
 
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local resumed = resumeNamedTimer("Demonnic", "DemonVitals")
+
local ok, err = pauseSpeedwalk()
if resumed then
+
if not ok then
   cecho("DemonVitals resumed!")
+
   debugc(f"Error: unable to pause speedwalk because {err}\n")
else
+
   return
   cecho("DemonVitals doesn't exist, so cannot resume it.")
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setButtonState==
+
==registerMapInfo==
;setButtonState(ButtonNameOrID, checked)
+
;registerMapInfo(label, function)
:Sets the state of a check-able ("push-down") type button from any Mudlet item's script - but does not cause the script or one of the commands associated with that button to be run/sent.
+
 
: See also: [[#getButtonState|getButtonState()]].
+
Adds an extra 'map info' to the mapper widget which can be used to display custom information.
{{MudletVersion|4.13}}
+
 
 +
: See also: [[#killMapInfo|killMapInfo()]], [[#enableMapInfo|enableMapInfo()]], [[#disableMapInfo|disableMapInfo()]]
 +
 
 +
{{MudletVersion|4.11}}
 +
 
 +
{{note}}
 +
You can register multiple map infos - just give them unique names and toggle whichever ones you need.
  
 
;Parameters
 
;Parameters
* ''ButtonNameOrID:''
+
* ''label:''
: The name of the button as a string or a unique ID (positive) integer number {for a name only one matching one will be affected - it will be the same one that the matching [[#getButtonState|getButtonState()]] reports upon}.
+
: 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.
* ''checked:''
+
* ''function:''
: boolean value that indicated whether the state required is down (''true'') or up (''false'').  
+
: Callback function that will be responsible for returning information how to draw map info fragment.
  
;Returns:
+
Callback function is called with following arguments:
* A boolean value indicating ''true'' if the visible state was actually changed, i.e. had any effect. This function will return a ''nil'' and a suitable error message if the identifying name or ID was not found or was not a check-able (push-down) button item (i.e. was a non-checkable button or a menu or a toolbar instead).
+
* ''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}}
 +
Map info is registered in disabled state, you need to enable it through script or by selecting checkbox under mapper.
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- inside, for example, an initialization script for a GUI package:
+
registerMapInfo("My very own handler!", function(roomId, selectionSize, areaId, displayedArea)  
setButtonState("Sleep", false)
+
  return string.format("RoomId: %d\nNumbers of room selected: %d\nAreaId: %d\nDisplaying area: %d", roomId, selectionSize, areaId, displayedArea),
setButtonState("Sit", false)
+
  true, true, 0, 255, 0
-- these are going to be used as "radio" buttons where setting one
+
end)
-- of them will unset all the others, they will each need something
+
enableMapInfo("My very own handler!")
-- similar in their own scripts to unset all the others in the set
 
-- and also something to prevent them from being unset by clicking
 
-- on themselves:
 
setButtonState("Wimpy", true)
 
setButtonState("Defensive", false)
 
setButtonState("Normal", false)
 
setButtonState("Brave", false)
 
if character.type == "Warrior" then
 
    -- Only one type has this mode - and it can only be reset by
 
    -- something dying (though that could be us!)
 
    setButtonState("Beserk!!!", false)
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setConsoleBufferSize==
+
Example will display something like that:
;setConsoleBufferSize([consoleName], linesLimit, sizeOfBatchDeletion)
 
:Sets the maximum number of lines a buffer (main window or a miniconsole) can hold. Default is 10,000.
 
:Returns nothing on success (up to '''Mudlet 4.16''') or ''true'' (from '''Mudlet 4.17'''); ''nil'' and an error message on failure.
 
  
;Parameters
+
[[File:Map-info-example.png]]
* ''consoleName:''
 
: (optional) The name of the window. If omitted, uses the main console.
 
* ''linesLimit:''
 
: Sets the amount of lines the buffer should have.
 
{{note}} Mudlet performs extremely efficiently with even huge numbers, but there is of course a limit to your computer's memory. As of Mudlet 4.7+, this amount will be capped to that limit on macOS and Linux (on Windows, it's capped lower as Mudlet on Windows is 32bit).
 
* ''sizeOfBatchDeletion:''
 
: Specifies how many lines should Mudlet delete at once when you go over the limit - it does it in bulk because it's efficient to do so.
 
  
;Example
+
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">
-- sets the main windows size to 1 million lines maximum - which is more than enough!
+
registerMapInfo("Alert", function()
setConsoleBufferSize("main", 1000000, 1000)
+
  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>
 
</syntaxhighlight>
  
==setProfileIcon==
+
==resumeSpeedwalk==
;setProfileIcon(iconPath)
+
;resumeSpeedwalk()
:Set a custom icon for this profile in the connection screen.
 
  
:Returns true if successful, or nil+error message if not.
+
:Continues a speedwalk paused using [[#pauseSpeedwalk|pauseSpeedwalk()]]
 +
: See also: [[#speedwalk|speedwalk()]], [[#pauseSpeedwalk|pauseSpeedwalk()]], [[#stopSpeedwalk|stopSpeedwalk()]]
 +
 
 +
{{MudletVersion|4.13}}
  
:See also: [[#resetProfileIcon|resetProfileIcon()]].
+
<syntaxhighlight lang="lua">
 +
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")
 +
</syntaxhighlight>
  
{{MudletVersion|4.0}}
+
==removeCustomLine==
 +
;removeCustomLine(roomID, direction)
  
;Parameters
+
:Removes the custom exit line that's associated with a specific exit of a room.
* ''iconPath:''
+
:See also: [[#addCustomLine|addCustomLine()]], [[#getCustomLines|getCustomLines()]]
: Full location of the icon - can be .png or .jpg with ideal dimensions of 120x30.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- set a custom icon that is located in an installed package called "mypackage"
+
-- remove custom exit line that starts in room 315 going north
setProfileIcon(getMudletHomeDir().."/mypackage/icon.png")
+
removeCustomLine(315, "n")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setScript==
+
==removeMapEvent==
;setScript(scriptName, luaCode, [occurrence])
+
;removeMapEvent(event name)
: Sets the script's Lua code, replacing existing code. If you have many scripts with the same name, use the 'occurrence' parameter to choose between them.
 
: If you'd like to add code instead of replacing it, have a look at [[Manual:Lua_Functions#appendScript|appendScript()]].
 
: Returns -1 if the script isn't found - to create a script, use [[Manual:Lua_Functions#permScript|permScript()]].
 
  
: See also: [[Manual:Lua_Functions#permScript|permScript()]], [[Manual:Lua_Functions#enableScript|enableScript()]], [[Manual:Lua_Functions#disableScript|disableScript()]], [[Manual:Lua_Functions#getScript|getScript()]], [[Manual:Lua_Functions#appendScript|appendScript()]]
+
: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()]]
  
;Returns
+
;Example
* a unique id number for that script.
+
<syntaxhighlight lang="lua">
 +
addMapEvent("room a", "onFavorite") -- add one to the general menu
 +
removeMapEvent("room a") -- removes the said menu
 +
</syntaxhighlight>
 +
 
 +
==removeMapMenu==
 +
;removeMapMenu(menu name)
  
;Parameters
+
:Removes the given submenu from a mappers right-click menu. You can add custom ones with [[#addMapMenu | addMapMenu()]].
* ''scriptName'': name of the script to change the code.
+
: See also: [[#addMapMenu | addMapMenu()]], [[#getMapMenus | getMapMenus()]], [[#removeMapEvent | removeMapEvent()]]
* ''luaCode'': new Lua code to set.
 
* ''occurrence'': The position of the script. Optional, defaults to 1 (first).
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- make sure a script named "testscript" exists first, then do:
+
addMapMenu("Test") -- add submenu to the general menu
setScript("testscript", [[echo("This is a test\n")]], 1)
+
removeMapMenu("Test") -- removes that same menu again
 
</syntaxhighlight>
 
</syntaxhighlight>
{{MudletVersion|4.8}}
 
  
==setStopWatchName==
+
==removeSpecialExit==
;setStopWatchName(watchID/currentStopWatchName, newStopWatchName)
+
;removeSpecialExit(roomID, command)  
  
;Parameters
+
:Removes the special exit which is accessed by ''command'' from the room with the given ''roomID''.
* ''watchID'' (number) / ''currentStopWatchName'' (string): The stopwatch ID you get from [[Manual:Lua_Functions#createStopWatch|createStopWatch()]] or the name supplied to that function at that time, or previously applied with this function.
+
:See also: [[#addSpecialExit|addSpecialExit()]], [[#clearSpecialExits|clearSpecialExits()]]
* ''newStopWatchName'' (string): The name to use for this stopwatch from now on.
 
  
;Returns
+
;Example
* ''true'' on success, ''nil'' and an error message if no matching stopwatch is found.
+
<syntaxhighlight lang="lua">
 +
addSpecialExit(1, 2, "pull rope") -- add a special exit from room 1 to room 2
 +
removeSpecialExit(1, "pull rope") -- removes the exit again
 +
</syntaxhighlight>
  
{{note}} Either ''currentStopWatchName'' or ''newStopWatchName'' may be empty strings: if the first of these is so then the ''lowest'' ID numbered stopwatch without a name is chosen; if the second is so then an existing name is removed from the chosen stopwatch.
+
==resetRoomArea==
 +
;resetRoomArea (roomID)
  
==setStopWatchPersistence==
+
: 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.
;setStopWatchPersistence(watchID/watchName, state)
 
  
;Parameters
+
: See also: [[#setRoomArea | setRoomArea()]], [[#getRoomArea | getRoomArea()]]
* ''watchID'' (number) / ''watchName'' (string): The stopwatch ID you get from [[Manual:Lua_Functions#createStopWatch|createStopWatch()]] or the name supplied to that function or applied later with [[Manual:Lua_Functions#setStopWatchName|setStopWatchName()]]
 
* ''state'' (boolean): if ''true'' the stopWatch will be saved.
 
  
;Returns
+
;Example
* ''true'' on success, ''nil'' and an error message if no matching stopwatch is found.
+
<syntaxhighlight lang="lua">
 +
resetRoomArea(3143)
 +
</syntaxhighlight>
  
:Sets or resets the flag so that the stopwatch is saved between sessions or after a [[Manual:Miscellaneous_Functions#resetProfile|resetProfile()]] call. If set then, if ''stopped'' the elapsed time recorded will be unchanged when the stopwatch is reloaded in the next session; if ''running'' the elapsed time will continue to increment and it will include the time that the profile was not loaded, therefore it can be used to measure events in real-time, outside of the profile!
+
==resizeMapWidget==
 +
;resizeMapWidget(width, height)
 +
:resizes a map window with given width, height.
 +
: See also: [[#openMapWidget|openMapWidget()]], [[#closeMapWidget|closeMapWidget()]], [[#moveMapWidget|moveMapWidget()]]
  
{{note}} When a persistent stopwatch is reloaded in a later session (or after a use of ''resetProfile()'') the stopwatch may not be allocated the same ID number as before - therefore it is advisable to assign any persistent stopwatches a name, either when it is created or before the session is ended.
+
{{MudletVersion|4.7}}
 
 
==setTriggerStayOpen==
 
;setTriggerStayOpen(name, number of lines)
 
:Sets for how many more lines a trigger script should fire or a chain should stay open after the trigger has matched - so this allows you to extend or shorten the ''fire length'' of a trigger. The main use of this function is to close a chain when a certain condition has been met.
 
  
 
;Parameters
 
;Parameters
* ''name:'' The name of the trigger which has a fire length set (and which opens the chain).
+
* ''width:''
* ''number of lines'': 0 to close the chain, or a positive number to keep the chain open that much longer.
+
: 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.
  
;Examples
+
==roomExists==
<syntaxhighlight lang="lua">
+
;roomExists(roomID)
-- if you have a trigger that opens a chain (has some fire length) and you'd like it to be closed
 
-- on the next prompt, you could make a prompt trigger inside the chain with a script of:
 
setTriggerStayOpen("Parent trigger name", 0)
 
-- to close it on the prompt!
 
</syntaxhighlight>
 
  
==startStopWatch==
+
:Returns a boolean true/false depending if the room with that ID exists (is created) or not.
;startStopWatch(watchName or watchID, [resetAndRestart])
 
  
:Stopwatches can be stopped (with [[Manual:Lua_Functions#stopStopWatch|stopStopWatch()]]) and then re-started any number of times. '''To ensure backwards compatibility, if the stopwatch is identified by a ''numeric'' argument then, ''unless a second argument of false is supplied as well'' this function will also reset the stopwatch to zero and restart it - whether it is running or not'''; otherwise only a stopped watch can be started and only a started watch may be stopped. Trying to repeat either will produce a nil and an error message instead; also the recorded time is no longer reset so that they can now be used to record a total of isolated periods of time like a real stopwatch.
+
==roomLocked==
 +
;locked = roomLocked(roomID)
  
:See also: [[Manual:Lua_Functions#createStopWatch|createStopWatch()]],  [[Manual:Lua_Functions#stopStopWatch|stopStopWatch()]]
+
:Returns true or false whenever a given room is locked.
 +
: See also: [[#lockRoom|lockRoom()]]
  
;Parameters
+
;Example
* ''watchID''/''watchName'': The stopwatch ID you get with [[Manual:Lua_Functions#createStopWatch|createStopWatch()]], or from '''4.4.0''' the name assigned with that function or [[Manual:Lua_Functions#setStopWatchName|setStopWatchName()]].
 
* ''resetAndRestart'': Boolean flag needed (as ''false'') to make the function from '''4.4.0''', when supplied with a numeric watch ID, to '''not''' reset the stopwatch and only start a previously stopped stopwatch. This behavior is automatic when a string watch name is used to identify the stopwatch but differs from how the function behaved prior to that version.
 
 
 
;Returns
 
* ''true'' on success, ''nil'' and an error message if no matching stopwatch is found or if it cannot be started (because the later style behavior was indicated and it was already running).
 
 
 
;Examples
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- this is a common pattern for re-using stopwatches prior to 4.4.0 and starting them:
+
echo(string.format("Is room #4545 locked? %s.", roomLocked(4545) and "Yep" or "Nope"))
watch = watch or createStopWatch()
 
startStopWatch(watch)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
:: After 4.4.0 the above code will work the same as it does not provide a second argument to the ''startStopWatch()'' function - if a ''false'' was used there it would be necessary to call ''stopStopWatch(...)'' and then ''resetStopWatch(...)'' before using ''startStopWatch(...)'' to re-use the stopwatch if the ID form is used, '''this is thus not quite the same behavior but it is more consistent with the model of how a real stopwatch would act.'''
+
==saveJsonMap==
 
+
; saveJsonMap([pathFileName])
==stopAllNamedTimers==
+
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.  
; stopAllNamedTimers(userName)
 
  
:Stops all named timers for userName and prevents them from firing any more. Information is retained and timers can be resumed.
+
: See also: [[#loadJsonMap|loadJsonMap()]]
 +
{{MudletVersion|4.11.0}}
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]], [[Manual:Lua_Functions#resumeNamedTimer|resumeNamedTimer()]]
+
; Parameters:
 +
* ''pathFileName'' (optional in Mudlet 4.12+): a string that is an absolute path and file name to save the data into.
  
{{MudletVersion|4.14}}
+
; Returns:
 +
* ''true'' on success
 +
* ''nil'' and an error message on failure.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
stopAllNamedTimers("Demonnic") -- emergency stop situation, most likely.
+
saveJsonMap(getMudletHomeDir() .. "/map.json")
 +
 
 +
true
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==stopNamedTimer==
+
==saveMap==
; success = stopNamedTimer(userName, handlerName)
+
;saveMap([location], [version])
 
 
:Stops a named timer with name handlerName and prevents it from firing any more. Information is stored so it can be resumed later if desired.
 
 
 
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#resumeNamedTimer|resumeNamedTimer()]]
 
  
{{MudletVersion|4.14}}
+
:Saves the map to a given location, and returns true on success. The location folder needs to be already created for save to work. You can also save the map in the Mapper settings tab.
  
 
;Parameters
 
;Parameters
* ''userName:''
+
* ''location''
: The user name the event handler was registered under.
+
: (optional) save the map to the given location if provided, or the default one otherwise.
* ''handlerName:''
+
* ''version''
: The name of the handler to stop. Same as used when you called [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
+
: (optional) map version as a number to use when saving (Mudlet 3.17+)
  
;Returns
+
: See also: [[#loadMap|loadMap()]]
* true if successful, false if it didn't exist or was already stopped
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local stopped = stopNamedTimer("Demonnic", "DemonVitals")
+
local savedok = saveMap(getMudletHomeDir().."/my fancy map.dat")
if stopped then
+
if not savedok then
   cecho("DemonVitals stopped!")
+
   echo("Couldn't save :(\n")
 
else
 
else
   cecho("DemonVitals doesn't exist or already stopped; either way it won't fire any more.")
+
   echo("Saved fine!\n")
 
end
 
end
 +
 +
-- save with a particular map version
 +
saveMap(20)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==stopStopWatch==
+
==searchAreaUserData==
;stopStopWatch(watchID or watchName)
+
;searchAreaUserData(area number | area name[, case-sensitive [, exact-match]])
:"Stops" (though see the note below) the stop watch and returns (only the '''first''' time it is called after the stopwatch has been set running with [[Manual:Lua_Functions#startStopWatch|startStopWatch()]]) the elapsed time as a number of seconds, with a decimal portion give a resolution in milliseconds (thousandths of a second). You can also retrieve the current time without stopping the stopwatch with [[Manual:Lua_Functions#getStopWatchTime|getStopWatchTime()]], [[Manual:Lua_Functions#getBrokenDownStopWatchTime|getBrokenDownStopWatchTime()]].
+
: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.
  
:See also: [[Manual:Lua_Functions#createStopWatch|createStopWatch()]]
+
==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;
  
;Parameters
+
::If no rooms are found, then an empty table is returned.
* ''watchID:'' The stopwatch ID you get with [[Manual:Lua_Functions#createStopWatch|createStopWatch()]] or from Mudlet '''4.4.0''' the name given to that function or later set with [[Manual:Lua_Functions#setStopWatchName|setStopWatchName()]].
 
  
;Returns
+
: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.
* the elapsed time as a floating-point number of seconds - it may be negative if the time was previously adjusted/preset to a negative amount (with [[Manual:Lua_Functions#adjustStopWatch|adjustStopWatch()]]) and that period has not yet elapsed.
 
  
 
;Examples
 
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- this is a common pattern for re-using stopwatches and starting them:
+
-- show the behavior when given a room number:
watch = watch or createStopWatch()
+
display(searchRoom(3088))
startStopWatch(watch)
+
"The North Road South of Taren Ferry"
  
-- do some long-running code here ...
+
-- 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.
  
print("The code took: "..stopStopWatch(watch).."s to run.")
+
-- shows all rooms containing the text in ONLY the letter-case provided:
 +
display(searchRoom("North road",true,false))
 +
{
 +
  [3114] = "Bend in North road",
 +
  [3115] = "North road",
 +
  [3117] = "North road",
 +
}
 +
 
 +
-- shows all rooms containing ONLY that text in either letter-case:
 +
lua searchRoom("North road",false,true)
 +
{
 +
  [3115] = "North road",
 +
  [3116] = "North Road",
 +
  [3117] = "North road"
 +
}
 +
 
 +
-- shows all rooms containing only and exactly the given text:
 +
lua searchRoom("North road",true,true)
 +
{
 +
  [3115] = "North road",
 +
  [3117] = "North road"
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
{{note}} Technically, with both options (case-sensitive and exact-match) set to true, one could just return a list of numbers as we know precisely what the string will be, but it was kept the same for maximum flexibility in user scripts.
  
==tempAnsiColorTrigger==
+
==searchRoomUserData==  
;tempAnsiColorTrigger(foregroundColor[, backgroundColor], code[, expireAfter])
+
;searchRoomUserData([key, [value]])
:This is an alternative to [[Manual:Lua_Functions#tempColorTrigger|tempColorTrigger()]] which supports the full set of 256 ANSI color codes directly and makes a color trigger that triggers on the specified foreground and background color. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
+
: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:
  
;Parameters
+
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#getRoomUserDataKeys|getRoomUserDataKeys()]], [[#setRoomUserData|setRoomUserData()]]
* ''foregroundColor:'' The foreground color you'd like to trigger on.
 
* ''backgroundColor'': The background color you'd like to trigger on.
 
* ''code to do'': The code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function.
 
* ''expireAfter'': Delete trigger after a specified number of matches. You can make a trigger match not count towards expiration by returning true after it fires.
 
  
''BackgroundColor'' and/or ''expireAfter'' may be omitted.
+
;searchRoomUserData(key, value)
  
;Color codes (note that the values greater than or equal to zero are the actual number codes that ANSI and the game server uses for the 8/16/256 color modes)
+
:Reports a (sorted) list of all room ids with user data with the given "value" for the given (case sensitive) "key".
  
::Special codes (may be extended in the future):
+
;searchRoomUserData(key)
:::-2 = default text color (what is used after an ANSI SGR 0 m code that resets the foreground and background colors to those set in the preferences)
 
:::-1 = ignore (only '''one''' of the foreground or background codes can have this value - otherwise it would not be a ''color'' trigger!)
 
  
::ANSI 8-color set:
+
:Reports a (sorted) list of the unique values from all rooms with user data with the given (case sensitive) "key".  
:::0 = (dark) black
 
:::1 = (dark) red
 
:::2 = (dark) green
 
:::3 = (dark) yellow
 
:::4 = (dark) blue
 
:::5 = (dark) magenta
 
:::6 = (dark) cyan
 
:::7 = (dark) white {a.k.a. light gray}
 
  
::Additional colors in 16-color set:
+
;searchRoomUserData()
:::8 = light black {a.k.a. dark gray}
 
:::9 = light red
 
:::10 = light green
 
:::11 = light yellow
 
:::12 = light blue
 
:::13 = light magenta
 
:::14 = light cyan
 
:::15 = light white
 
  
::6 x 6 x 6 RGB (216) colors, shown as a 3x2-digit hex code
+
: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.
:::16 = #000000
 
:::17 = #000033
 
:::18 = #000066
 
:::...
 
:::229 = #FFFF99
 
:::230 = #FFFFCC
 
:::231 = #FFFFFF
 
  
::24 gray-scale, also show as a 3x2-digit hex code
+
{{MudletVersion|3.0}}
:::232 = #000000
 
:::233 = #0A0A0A
 
:::234 = #151515
 
:::...
 
:::253 = #E9E9E9
 
:::254 = #F4F4F4
 
:::255 = #FFFFFF
 
  
 
;Examples
 
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- This script will re-highlight all text in a light cyan foreground color on any background with a red foreground color
+
-- if I had stored the details of "named doors" as part of the room user data --
-- until another foreground color in the current line is being met. temporary color triggers do not offer match_all
+
display(searchRoomUserData("doorname_up"))
-- or filter options like the GUI color triggers because this is rarely necessary for scripting.
+
 
-- A common usage for temporary color triggers is to schedule actions on the basis of forthcoming text colors in a particular context.
+
--[[ could result in a list:
tempAnsiColorTrigger(14, -1, [[selectString(matches[1],1) fg("red")]])
+
{
-- or:
+
  "Eastgate",
tempAnsiColorTrigger(14, -1, function()
+
  "Northgate",
  selectString(matches[1], 1)
+
  "boulderdoor",
  fg("red")
+
  "chamberdoor",
end)
+
  "dirt",
 +
  "floorboards",
 +
  "floortrap",
 +
  "grate",
 +
  "irongrate",
 +
  "rockwall",
 +
  "tomb",
 +
  "trap",
 +
  "trapdoor"
 +
}]]
 +
 
 +
-- then taking one of these keys --
 +
display(searchRoomUserData("doorname_up","trapdoor"))
 +
 
 +
--[[ might result in a list:
 +
{
 +
  3441,
 +
  6113,
 +
  6115,
 +
  8890
 +
}
 +
]]</syntaxhighlight>
 +
 
 +
==setAreaName==
 +
;setAreaName(areaID or areaName, newName)
 +
 
 +
:Names, or renames an existing area to the new name. The area must be created first with [[#addAreaName|addAreaName()]] and it must be unique.
 +
 
 +
{{note}} parameter areaName is available since Mudlet 3.0.
 +
 
 +
:See also: [[#deleteArea|deleteArea()]], [[#addAreaName|addAreaName()]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
setAreaName(2, "My city")
  
-- match the trigger only 4 times
+
-- available since Mudlet 3.0
tempColorTrigger(14, -1, [[selectString(matches[1],1) fg("red")]], 4)
+
setAreaName("My old city name", "My new city name")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{MudletVersion|3.17}}
+
==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.
  
==tempAlias==
+
:Returns true if successfully set.
;aliasID = tempAlias(regex, code to do)
+
: See also: [[#clearAreaUserData|clearAreaUserData()]], [[#clearAreaUserDataItem|clearAreaUserDataItem()]], [[#getAllAreaUserData|getAllAreaUserData()]], [[#getAreaUserData|getAreaUserData()]], [[#searchAreaUserData|searchAreaUserData()]]
:Creates a temporary alias - temporary in the sense that it won't be saved when Mudlet restarts (unless you re-create it). The alias will go off as many times as it matches, it is not a one-shot alias. The function returns an ID for subsequent [[Manual:Lua_Functions#enableAlias|enableAlias()]], [[Manual:Lua_Functions#disableAlias|disableAlias()]] and [[Manual:Lua_Functions#killAlias|killAlias()]] calls.
 
  
;Parameters
+
{{MudletVersion|3.0}}
* ''regex:'' Alias pattern in regex.
 
* ''code to do:'' The code to do when the alias fires - wrap it in [[ ]].
 
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
myaliasID = tempAlias("^hi$", [[send ("hi") echo ("we said hi!")]])
+
-- can use it to store extra area details...
 +
setAreaUserData(34, "country", "Andor.")
  
-- you can also delete the alias later with:
+
-- or a sound file to play in the background (with a script that checks a room's area when entered)...
killAlias(myaliasID)
+
setAreaUserData(34, "backgroundSound", "/home/user/mudlet-data/soundFiles/birdsong.mp4")
  
-- tempAlias also accepts functions (and thus closures) - which can be an easier way to embed variables and make the code for an alias look less messy:
+
-- 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>
  
local variable = matches[2]
+
==setCustomEnvColor==
tempAlias("^hi$", function () send("hello, " .. variable) end)
+
;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|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.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
setRoomEnv(571, 200) -- change the room's environment ID to something arbitrary, like 200
 +
local r,g,b = unpack(color_table.blue)
 +
setCustomEnvColor(200, r,g,b, 255) -- set the color of environmentID 200 to blue
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==tempBeginOfLineTrigger==
+
==setDoor==
;tempBeginOfLineTrigger(part of line, code, expireAfter)
+
;setDoor(roomID, exitCommand, doorStatus)
:Creates a trigger that will go off whenever the part of line it's provided with matches the line right from the start (doesn't matter what the line ends with). The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls.
+
 
 +
:Creates or deletes a door in a room. Doors are purely visual - they don't affect pathfinding. You can use the information to adjust your speedwalking path based on the door information in a room, though.
 +
 
 +
:Doors CAN be set on stub exits ''- so that map makers can note if there is an obvious door to somewhere even if they do not (yet) know where it goes, perhaps because they do not yet have the key to open it!''
 +
 
 +
:Returns ''true'' if the change could be made, ''false'' if the input was valid but ineffective (door status was not changed), and ''nil'' with a message string on invalid input (value type errors).
 +
 
 +
: See also: [[#getDoors|getDoors()]]
  
 
;Parameters
 
;Parameters
* ''part of line'': start of the line that you'd like to match. This can also be regex.
+
* ''roomID:''
* ''code to do'': code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function (since Mudlet 3.5.0).
+
: Room ID to to create the door in.
* ''expireAfter'': Delete trigger after a specified number of matches (since Mudlet 3.11). You can make a trigger match not count towards expiration by returning true after it fires.
+
* ''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.
  
;Examples
+
* ''doorStatus:''
<syntaxhighlight lang="lua">
+
: 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).
mytriggerID = tempBeginOfLineTrigger("Hello", [[echo("We matched!")]])
 
  
--[[ now this trigger will match on any of these lines:
 
Hello
 
Hello!
 
Hello, Bob!
 
  
but not on:
+
;Example
Oh, Hello
+
<syntaxhighlight lang="lua">
Oh, Hello!
+
-- make a door on the east exit of room 4234 that is currently open
]]
+
setDoor(4234, 'e', 1)
  
-- or as a function:
+
-- remove a door from room 923 that points north
mytriggerID = tempBeginOfLineTrigger("Hello", function() echo("We matched!") end)
+
setDoor(923, 'n', 0)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
==setExit==
-- you can make the trigger match only a certain amount of times as well, 5 in this example:
+
;setExit(from roomID, to roomID, direction)
tempBeginOfLineTrigger("This is the start of the line", function() echo("We matched!") end, 5)
 
  
-- if you want a trigger match not to count towards expiration, return true. In this example it'll match 5 times unless the line is "Start of line and this is the end."
+
: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.
tempBeginOfLineTrigger("Start of line",  
 
function()
 
  if line == "Start of line and this is the end." then
 
    return true
 
  else
 
    return false
 
  end
 
end, 5)
 
</syntaxhighlight>
 
  
==tempButton==
+
:Returns ''false'' if the exit creation didn't work.
;tempButton(toolbar name, button text, orientation)
 
:Creates a temporary button. Temporary means, it will disappear when Mudlet is closed.
 
  
;Parameters:
+
: See also: [[#addSpecialExit|addSpecialExit()]]
* ''toolbar name'': The name of the toolbar to place the button into.
 
* ''button text'': The text to display on the button.
 
* ''orientation'': a number 0 or 1 where 0 means horizontal orientation for the button and 1 means vertical orientation for the button. This becomes important when you want to have more than one button in the same toolbar.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- makes a temporary toolbar with two buttons at the top of the main Mudlet window
+
-- alias pattern: ^exit (\d+) (\d+) (\w+)$
lua tempButtonToolbar("topToolbar", 0, 0)
+
-- so exit 1 2 5 will make an exit from room 1 to room 2 via north
lua tempButton("topToolbar", "leftButton", 0)
+
 
lua tempButton("topToolbar", "rightButton", 0)
+
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>
  
{{note}} ''This function is not that useful as there is no function yet to assign a Lua script or command to such a temporary button - though it may have some use to flag a status indication!''
+
This function can also delete exits from a room if you use it like so:
  
==tempButtonToolbar==
+
<syntaxhighlight lang="lua">setExit(from roomID, -1, direction)</syntaxhighlight>
;tempButtonToolbar(name, location, orientation)
 
:Creates a temporary button toolbar. Temporary means, it will disappear when Mudlet is closed.
 
  
;Parameters:
+
- which will delete an outgoing exit in the specified direction from a room.
* ''name'': The name of the toolbar.
+
 
* ''location'': a number from 0 to 3, where 0 means "at the top of the screen", 1 means "left side", 2 means "right side" and 3 means "in a window of its own" which can be dragged and attached to the main Mudlet window if needed.
+
==setExitStub==
* ''orientation'': a number 0 or 1, where 0 means horizontal orientation for the toolbar and 1 means vertical orientation for the toolbar. This becomes important when you want to have more than one toolbar in the same location of the window.
+
;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|getExitStubs()]], [[#connectExitStub|connectExitStub()]]
  
 
;Example
 
;Example
 +
Create an exit stub to the south from room 8:
 +
<syntaxhighlight lang="lua">
 +
setExitStub(8, "s", true)
 +
</syntaxhighlight>
 +
 +
How to delete all exit stubs in a room:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- makes a temporary toolbar with two buttons at the top of the main Mudlet window
+
for i,v in pairs(getExitStubs(roomID)) do
lua tempButtonToolbar("topToolbar", 0, 0)
+
  setExitStub(roomID, v,false)
lua tempButton("topToolbar", "leftButton", 0)
+
end
lua tempButton("topToolbar", "rightButton", 0)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==tempColorTrigger==
+
==setExitWeight==
;tempColorTrigger(foregroundColor, backgroundColor, code, expireAfter)
+
;setExitWeight(roomID, exitCommand, weight)
:Makes a color trigger that triggers on the specified foreground and background color. Both colors need to be supplied in form of these simplified ANSI 16 color mode codes. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
+
 
See also: [[Manual:Mudlet Object Functions#tempAnsiColorTrigger|tempAnsiColorTrigger]]
+
: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
 
;Parameters
* ''foregroundColor:'' The foreground color you'd like to trigger on (for ANSI colors, see [[Manual:Mudlet Object Functions#tempAnsiColorTrigger|tempAnsiColorTrigger]]).
+
* ''roomID:''
* ''backgroundColor'': The background color you'd like to trigger on (same as above).
+
: Room ID to to set the weight in.
* ''code to do'': The code to do when the trigger runs - wrap it in <code>[[</code> and <code>]]</code>, or give it a Lua function, ie. <code>function() <nowiki><your code here></nowiki> end</code> (since Mudlet 3.5.0).
+
* ''exitCommand:''
* ''expireAfter'': Delete trigger after a specified number of matches (since Mudlet 3.11). You can make a trigger match not count towards expiration by returning true after it fires.
+
: 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|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.
 +
:[[File:Mapper-regular-mode.png|none|thumb|640x640px|regular mode]][[File:Mapper-grid-mode.png|none|thumb|631x631px|grid mode]]
 +
 
 +
: See also: [[#getGridMode|getGridMode()]]
  
;Color codes
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
0 = default text color
+
setGridMode(55, true) -- set area with ID 55 to be in grid mode
1 = light black
 
2 = dark black
 
3 = light red
 
4 = dark red
 
5 = light green
 
6 = dark green
 
7 = light yellow
 
8 = dark yellow
 
9 = light blue
 
10 = dark blue
 
11 = light magenta
 
12 = dark magenta
 
13 = light cyan
 
14 = dark cyan
 
15 = light white
 
16 = dark white
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
;Examples
+
==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|clearMapUserData()]], [[#clearMapUserDataItem|clearMapUserDataItem()]], [[#getAllMapUserData|getAllMapUserData()]], [[#getMapUserData|getMapUserData()]]
 +
 
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- This script will re-highlight all text in blue foreground colors on a black background with a red foreground color
+
-- store general meta information about the map...
-- on a blue background color until another color in the current line is being met. temporary color triggers do not
+
setMapUserData("game_name", "Achaea Mudlet map")
-- offer match_all or filter options like the GUI color triggers because this is rarely necessary for scripting.  
+
 
-- A common usage for temporary color triggers is to schedule actions on the basis of forthcoming text colors in a particular context.
+
-- or who the author was
tempColorTrigger(9, 2, [[selectString(matches[1],1) fg("red") bg("blue")]])
+
setMapUserData("author", "Bob")
-- or:
 
tempColorTrigger(9, 2, function()
 
  selectString(matches[1], 1)
 
  fg("red")
 
  bg("blue")
 
end)
 
  
-- match the trigger only 4 times
+
-- can even store tables in it, using the built-in yajl.to_string function
tempColorTrigger(9, 2, [[selectString(matches[1],1) fg("red") bg("blue")]], 4)
+
setMapUserData("some table", yajl.to_string({game = "mud.com", port = 23}))
 +
display("Available game info in the map: ")
 +
display(yajl.to_value(getMapUserData("some table")))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==tempComplexRegexTrigger==
+
==setMapZoom==
;tempComplexRegexTrigger(name, regex, code, multiline, fg color, bg color, filter, match all, highlight fg color, highlight bg color, play sound file, fire length, line delta, expireAfter)
+
;setMapZoom(zoom[, areaID])
:Allows you to create a temporary trigger in Mudlet, using any of the UI-available options. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
+
 
:Returns the trigger ID or nil and an error message (on error).
+
: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
 
;Parameters
* ''name'' - The name you call this trigger. You can use this with [[Manual:Lua_Functions#killTrigger|killTrigger()]].
+
* ''zoom:''
* ''regex'' - The regular expression you want to match.
+
: floating point number that is at least 3.0 to set the zoom to.
* ''code'' - Code to do when the trigger runs. You need to wrap it in [[ ]], or give a Lua function (since Mudlet 3.5.0).
 
* ''multiline'' - Set this to 1, if you use multiple regex (see note below), and you need the trigger to fire only if all regex have been matched within the specified line delta. Then all captures will be saved in ''multimatches'' instead of ''matches''. If this option is set to 0, the trigger will fire when any regex has been matched.
 
* ''fg color'' - The foreground color you'd like to trigger on - '''Not currently implemented.'''
 
* ''bg color'' - The background color you'd like to trigger on - '''Not currently implemented.'''
 
* ''filter'' - Do you want only the filtered content (=capture groups) to be passed on to child triggers? Otherwise also the initial line.
 
* ''match all'' - Set to 1, if you want the trigger to match all possible occurrences of the regex in the line. When set to 0, the trigger will stop after the first successful match.
 
* ''highlight fg color'' - The foreground color you'd like your match to be highlighted in. e.g. <code>"yellow"</code>, <code>"#ff0"</code> or <code>"#ffff00"</code>
 
* ''highlight bg color'' - The background color you'd like your match to be highlighted in. e.g. <code>"red"</code>, <code>"#f00"</code> or <code>"#ff0000"</code>
 
* ''play sound file'' - Set to the name of the sound file you want to play upon firing the trigger. e.g. <code>"C:/windows/media/chord.wav"</code>
 
* ''fire length'' - Number of lines within which all condition must be true to fire the trigger.
 
* ''line delta'' - Keep firing the script for x more lines, after the trigger or chain has matched.
 
* ''expireAfter'' - Delete trigger after a specified number of matches (since Mudlet 3.11). You can make a trigger match not count towards expiration by returning true after it fires.
 
  
{{Note}} Set the options starting at ''multiline'' to 0, if you don't want to use those options. Otherwise enter 1 to activate or the value you want to use.
+
* ''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).
  
{{Note}} If you want to use the color option, you need to provide both fg and bg together. - '''Not currently implemented.'''
+
;Returns (only since '''Mudlet ''4.17.0''''')
 
+
* ''true'' on success
;Examples
+
* ''nil'' and an error message on failure.
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- This trigger will be activated on any new line received.
+
setMapZoom(10.0) -- zoom to a somewhat acceptable level, a bit big but easily visible connections
triggerNumber = tempComplexRegexTrigger("anyText", "^(.*)$", [[echo("Text received!")]], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil)
+
true
  
-- This trigger will match two different regex patterns:
+
setMapZoom(2.5 + getMapZoom(1), 1) -- zoom out the area with ID 1 by 2.5
tempComplexRegexTrigger("multiTrigger", "first regex pattern", [[]], 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil)
+
true
tempComplexRegexTrigger("multiTrigger", "second regex pattern", [[echo("Trigger matched!")]], 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{Note}} For making a multiline trigger like in the second example, you need to use the same trigger name and options, providing the new pattern to add. Note that only the last script given will be set, any others ignored.
+
{{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.
  
==tempExactMatchTrigger==
+
==setRoomArea==
;tempExactMatchTrigger(exact line, code, expireAfter)
+
;setRoomArea(roomID, newAreaID or newAreaName)
:Creates a trigger that will go off whenever the line from the game matches the provided line exactly (ends the same, starts the same, and looks the same). You don't need to use any of the regex symbols here (^ and $). The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
 
  
;Parameters
+
: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.
* ''exact line'': exact line you'd like to match.
+
 
* ''code'': code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function (since Mudlet 3.5.0).
+
: See also: [[#resetRoomArea|resetRoomArea()]]
* ''expireAfter'': Delete trigger after a specified number of matches (since Mudlet 3.11). You can make a trigger match not count towards expiration by returning true after it fires.
+
 
 +
==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. In versions prior to Mudlet 3.8, the symbol can be cleared by using "_" as the character. In Mudlet version 3.8 and higher, the symbol may be cleared with either a space <code>" "</code> or an empty string <code>""</code>.
 +
 
 +
;Game-related symbols for your map
 +
* [https://github.com/toddfast/game-icons-net-font toddfast's font] - 3000+ scalable vector RPG icons from [https://game-icons.net game-icons.net], as well as a script to download the latest icons and generate a new font.
 +
* Pixel Kitchen's [https://www.fontspace.com/donjonikons-font-f30607 Donjonikon Font] - 10x10 fantasy and RPG-related icons.
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
mytriggerID = tempExactMatchTrigger("You have recovered balance on all limbs.", [[echo("We matched!")]])
+
setRoomChar(431, "#")
  
-- as a function:
+
setRoomChar(123, "$")
mytriggerID = tempExactMatchTrigger("You have recovered balance on all limbs.", function() echo("We matched!") end)
 
  
-- expire after 4 matches:
+
-- emoji's work fine too, and if you'd like it coloured, set the font to Nojo Emoji in settings
tempExactMatchTrigger("You have recovered balance on all limbs.", function() echo("Got balance back!\n") end, 4)
+
setRoomChar(666, "👿")
 +
</syntaxhighlight>
  
-- you can also avoid expiration by returning true:
+
:'''Since Mudlet version 3.8 :''' this facility has been extended:
tempExactMatchTrigger("You have recovered balance on all limbs.", function() echo("Got balance back!\n") return true end, 4)
+
:* 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|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>
 
</syntaxhighlight>
  
==tempKey==
+
{{MudletVersion|4.11}}
;tempKey([modifier], key code, lua code)
 
:Creates a keybinding. This keybinding isn't temporary in the sense that it'll go off only once (it'll go off as often as you use it), but rather it won't be saved when Mudlet is closed.
 
  
: See also: [[#permKey|permKey()]], [[#killKey|killKey()]]
+
: See also: [[#unsetRoomCharColor|unsetRoomCharColor()]]
  
* ''modifier''
+
==setRoomCoordinates==
:(optional) modifier to use - can be one of ''mudlet.keymodifier.Control'', ''mudlet.keymodifier.Alt'', ''mudlet.keymodifier.Shift'', ''mudlet.keymodifier.Meta'', ''mudlet.keymodifier.Keypad'', or ''mudlet.keymodifier.GroupSwitch'' or the default value of ''mudlet.keymodifier.None'' which is used if the argument is omitted. To use multiple modifiers, add them together: ''(mudlet.keymodifier.Shift + mudlet.keymodifier.Control)''
+
;setRoomCoordinates(roomID, x, y, z)
* ''key code''
 
: actual key to use - one of the values available in ''mudlet.key'', e.g. ''mudlet.key.Escape'', ''mudlet.key.Tab'', ''mudlet.key.F1'', ''mudlet.key.A'', and so on. The list is a bit long to list out in full so it is [https://github.com/Mudlet/Mudlet/blob/development/src/mudlet-lua/lua/KeyCodes.lua#L2 available here].
 
* ''lua code'
 
: code you'd like the key to run - wrap it in [[ ]].
 
  
;Returns
+
: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).
* a unique id number for that key.
+
 
 +
{{note}} 0,0,0 is the center of the map.
  
 
;Examples
 
;Examples
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
keyID = tempKey(mudlet.key.F8, [[echo("hi")]])
+
-- alias pattern: ^set rc (-?\d+) (-?\d+) (-?\d+)$
 +
-- this sets the current room to the supplied coordinates
 +
setRoomCoordinates(roomID,x,y,z)
 +
centerview(roomID)
 +
</syntaxhighlight>
  
anotherKeyID = tempKey(mudlet.keymodifier.Control, mudlet.key.F8, [[echo("hello")]])
+
:You can make them relative asa well:
  
-- bind Ctrl+Shift+W:
+
<syntaxhighlight lang="lua">
tempKey(mudlet.keymodifier.Control + mudlet.keymodifier.Shift, mudlet.key.W, [[send("jump")]])
+
-- alias pattern: ^src (\w+)$
  
-- delete it if you don't like it anymore
+
local x,y,z = getRoomCoordinates(previousRoomID)
killKey(keyID)
+
local dir = matches[2]
  
-- tempKey also accepts functions (and thus closures) - which can be an easier way to embed variables and make the code for tempKeys look less messy:
+
if dir == "n" then
 
+
  y = y+1
tempKey(mudlet.key.F8, function() echo("Hi\n") end)
+
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>
 
</syntaxhighlight>
  
==tempLineTrigger==
+
==setRoomEnv==
;tempLineTrigger(from, howMany, code)
+
;setRoomEnv(roomID, newEnvID)
:Temporary trigger that will fire on ''n'' consecutive lines following the current line. This is useful to parse output that is known to arrive in a certain line margin or to delete unwanted output from the game - the trigger does not require any patterns to match on. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
 
  
;Parameters:
+
: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.
* ''from'': from which line after this one should the trigger activate - 1 will activate right on the next line.
+
: See also: [[#setCustomEnvColor|setCustomEnvColor()]]
* ''howMany'': how many lines to run for after the trigger has activated.
 
* ''code'': code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function (since Mudlet 3.5.0).
 
  
;Example:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Will fire 3 times with the next line from the game
+
setRoomEnv(551, 34) -- set room with the ID of 551 to the environment ID 34
tempLineTrigger(1, 3, function() print(" trigger matched!") end)
+
</syntaxhighlight>
  
-- Will fire 5 lines after the current line and fire twice on 2 consecutive lines
+
==setRoomIDbyHash==
tempLineTrigger(5, 2, function() print(" trigger matched!") end, 7)
+
;setRoomIDbyHash(roomID, hash)
</syntaxhighlight>
 
  
==tempPromptTrigger==
+
:Sets the hash to be associated with the given roomID. See also [[#getRoomIDbyHash|getRoomIDbyHash()]].
;tempPromptTrigger(code, expireAfter)
 
:Temporary trigger that will match on the games prompt. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
 
  
{{note}} If the trigger is not working, check that the '''N:''' bottom-right has a number. This feature requires telnet Go-Ahead to be enabled in the game.  
+
:If the room was associated with a different hash, or vice versa, that association will be superseded.
  
{{MudletVersion|3.6}}
+
==setRoomName==
 +
;setRoomName(roomID, newName)
  
;Parameters:
+
:Renames an existing room to a new name.
* ''code'':
 
: code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function.
 
* ''expireAfter'': (available in Mudlet 3.11+)
 
: Delete trigger after a specified number of matches. You can make a trigger match not count towards expiration by returning true after it fires.
 
  
;Example:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
tempPromptTrigger(function()
+
setRoomName(534, "That evil room I shouldn't visit again.")
  echo("hello! this is a prompt!")
+
lockRoom(534, true) -- and lock it just to be safe
end)
+
</syntaxhighlight>
  
-- match only 2 times:
+
==setRoomUserData==
tempPromptTrigger(function()
+
;setRoomUserData(roomID, key (as a string), value (as a string))
  echo("hello! this is a prompt!")
 
end, 2)
 
  
-- match only 2 times, unless the prompt is "55 health."
+
: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.  
tempPromptTrigger(function()
 
  if line == "55 health." then return true end
 
end, 2)
 
</syntaxhighlight>
 
  
==tempRegexTrigger==
+
:Returns true if successfully set.
;tempRegexTrigger(regex, code, expireAfter)
+
: See also: [[#clearRoomUserData|clearRoomUserData()]], [[#clearRoomUserDataItem|clearRoomUserDataItem()]], [[#getAllRoomUserData|getAllRoomUserData()]], [[#getRoomUserData|getRoomUserData()]], [[#searchRoomUserData|searchRoomUserData()]]
:Creates a temporary regex trigger that executes the code whenever it matches. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
 
  
;Parameters:
 
* ''regex:'' regular expression that lines will be matched on.
 
* ''code'': code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function (since Mudlet 3.5.0).
 
* ''expireAfter'': Delete trigger after a specified number of matches (since Mudlet 3.11). You can make a trigger match not count towards expiration by returning true after it fires.
 
  
;Examples:
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a non-duplicate trigger that matches on any line and calls a function
+
-- can use it to store room descriptions...
html5log = html5log or {}
+
setRoomUserData(341, "description", "This is a plain-looking room.")
if html5log.trig then killTrigger(html5log.trig) end
 
html5log.trig = tempRegexTrigger("^", [[html5log.recordline()]])
 
-- or a simpler variant:
 
html5log.trig = tempRegexTrigger("^", html5log.recordline)
 
  
-- only match 3 times:
+
-- or whenever it's outdoors or not...
tempRegexTrigger("^You prick (.+) twice in rapid succession with", function() echo("Hit "..matches[2].."!\n") end, 3)
+
setRoomUserData(341, "outdoors", "true")
  
-- since Mudlet 4.11+ you can use named capturing groups
+
-- how how many times we visited that room
tempRegexTrigger("^You see (?<material>\\w+) axe inside chest\\.", function() echo("\nAxe is " .. matches.material) end)
+
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>
 
</syntaxhighlight>
  
==tempTimer==
+
==setRoomWeight==
;tempTimer(time, code to do[, repeating])
+
;setRoomWeight(roomID, weight)
:Creates a temporary one-shot timer and returns the timer ID, which you can use with [[Manual:Lua_Functions#enableTimer|enableTimer()]], [[Manual:Lua_Functions#disableTimer|disableTimer()]] and [[Manual:Lua_Functions#killTimer|killTimer()]] functions. You can use 2.3 seconds or 0.45 etc. After it has fired, the timer will be deactivated and destroyed, so it will only go off once. Here is a [[Manual:Introduction#Timers|more detailed introduction to tempTimer]].
+
 
 +
: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()]]
  
;Parameters
 
* ''time:'' The time in seconds for which to set the timer for - you can use decimals here for precision. The timer will go off ''x'' given seconds after you make it.
 
* ''code to do'': The code to do when the timer is up - wrap it in [[ ]], or provide a Lua function.
 
* ''repeating'': (optional) if true, keep firing the timer over and over until you kill it (available in Mudlet 4.0+).
 
  
;Examples
+
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- wait half a second and then run the command
+
setRoomWeight(1532, 3) -- avoid using this room if possible, but don't completely ignore it
tempTimer(0.5, function() send("kill monster") end)
+
</syntaxhighlight>
 +
 
 +
 
 +
==speedwalk==
 +
;speedwalk(dirString, backwards, delay, show)
  
-- echo between 1 and 5 seconds after creation
+
: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.
tempTimer(math.random(1, 5), function() echo("hi!") end)
 
  
-- or an another example - two ways to 'embed' variable in a code for later:
+
:Call the function by doing: <code>speedwalk("YourDirectionsString", true/false, delaytime, true/false)</code>
local name = matches[2]
 
tempTimer(2, [[send("hello, ]]..name..[[ !")]])
 
-- or:
 
tempTimer(2, function()
 
  send("hello, "..name)
 
end)
 
  
-- create a looping timer
+
: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.)
timerid = tempTimer(1, function() display("hello!") end, true)
 
  
-- later when you'd like to stop it:
+
: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.)
killTimer(timerid)
 
</syntaxhighlight>
 
  
{{note}} Double brackets, e.g: [[ ]] can be used to quote strings in Lua. The difference to the usual `" " quote syntax is that `[[ ]] also accepts the character ". Consequently, you don’t have to escape the " character in the above script. The other advantage is that it can be used as a multiline quote, so your script can span several lines.
+
: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.
  
{{note}} Lua code that you provide as an argument is compiled from a string value when the timer fires. This means that if you want to pass any parameters by value e.g. you want to make a function call that uses the value of your variable myGold as a parameter you have to do things like this:
+
: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">
 
<syntaxhighlight lang="lua">
tempTimer( 3.8, [[echo("at the time of the tempTimer call I had ]] .. myGold .. [[ gold.")]] )
+
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.
  
-- tempTimer also accepts functions (and thus closures) - which can be an easier way to embed variables and make the code for timers look less messy:
+
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.
  
local variable = matches[2]
+
speedwalk("5sw - 3s - 2n - w", true)
tempTimer(3, function () send("hello, " .. variable) end)
+
-- 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>
  
==tempTrigger==
+
{{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>
;tempTrigger(substring, code, expireAfter)
+
And have ''^//(.+)$'' execute: <code>speedwalk(matches[2], true, 0.7)</code>
:Creates a substring trigger that executes the code whenever it matches. The function returns the trigger ID for subsequent [[Manual:Lua_Functions#enableTrigger|enableTrigger()]], [[Manual:Lua_Functions#disableTrigger|disableTrigger()]] and [[Manual:Lua_Functions#killTrigger|killTrigger()]] calls. The trigger is temporary in the sense that it won't stay when you close Mudlet, and it will go off multiple times until you disable or destroy it. You can also make it be temporary and self-delete after a number of matches with the ''expireAfter'' parameter.
+
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()
  
;Parameters:
+
:Stops a speedwalk started using [[#speedwalk|speedwalk()]]
* ''substring'': The substring to look for - this means a part of the line. If your provided text matches anywhere within the line from the game, the trigger will go off.
+
: See also: [[#pauseSpeedwalk|pauseSpeedwalk()]], [[#resumeSpeedwalk|resumeSpeedwalk()]], [[#speedwalk|speedwalk()]]
* ''code'': The code to do when the trigger runs - wrap it in [[ ]], or give it a Lua function (since Mudlet 3.5)
+
 
* ''expireAfter'': Delete trigger after a specified number of matches (since Mudlet 3.11). You can make a trigger match not count towards expiration by returning true after it fires.
+
{{MudletVersion|4.13}}
  
Example:
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- this example will highlight the contents of the "target" variable.
+
local ok, err = stopSpeedwalk()
-- it will also delete the previous trigger it made when you call it again, so you're only ever highlighting one name
+
if not ok then
if id then killTrigger(id) end
+
  cecho(f"\n<red>Error:<reset> {err}")
id = tempTrigger(target, [[selectString("]] .. target .. [[", 1) fg("gold") resetFormat()]])
+
  return
 +
end
 +
cecho(f"\n<green>Success:<reset> speedwalk stopped")
 +
</syntaxhighlight>
  
-- you can also write the same line as:
+
==unHighlightRoom==
id = tempTrigger(target, function() selectString(target, 1) fg("gold") resetFormat() end)
+
;unHighlightRoom(roomID)
  
-- or like so if you have a highlightTarget() function somewhere
+
:Unhighlights a room if it was previously highlighted and restores the rooms original environment color.
id = tempTrigger(target, highlightTarget)
+
: See also: [[#highlightRoom|highlightRoom()]]
</syntaxhighlight>
 
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- a simpler trigger to replace "hi" with "bye" whenever you see it
+
unHighlightRoom(4534)
tempTrigger("hi", [[selectString("hi", 1) replace("bye")]])
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
==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.
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- this trigger will go off only 2 times
+
unsetRoomCharColor(2031)
tempTrigger("hi", function() selectString("hi", 1) replace("bye") end, 2)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
{{MudletVersion|4.11}}
-- table to store our trigger IDs in
 
nameIDs = nameIDs or {}
 
-- delete any existing triggers we've already got
 
for _, id in ipairs(nameIDs) do killTrigger(id) end
 
  
-- create new ones, avoiding lots of ]] [[ to embed the name
+
==updateMap==
for _, name in ipairs{"Alice", "Ashley", "Aaron"} do
+
;updateMap()
  nameIDs[#nameIDs+1] = tempTrigger(name, function() print(" Found "..name.."!") end)
 
end
 
</syntaxhighlight>
 
  
;Additional Notes:
+
:Updates the mapper display (redraws it). Use this function if you've edited the map via script and would like the changes to show.
tempTriggers begin matching on the same line they're created on.  
 
  
If your ''code'' deletes and recreates the tempTrigger, or if you ''send'' a matching command again, it's possible to get into an infinite loop.
+
: See also: [[#centerview|centerview()]]
  
Make use of the ''expireAfter'' parameter, [[Manual:Lua_Functions#disableTrigger|disableTrigger()]], or [[Manual:Lua_Functions#killTrigger|killTrigger()]] to prevent a loop from forming.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- delete a some room
 +
deleteRoom(500)
 +
-- now make the map show that it's gone
 +
updateMap()
 +
</syntaxhighlight>
  
 
[[Category:Mudlet Manual]]
 
[[Category:Mudlet Manual]]
 
[[Category:Mudlet API]]
 
[[Category:Mudlet API]]

Latest revision as of 22:28, 12 January 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.
  • 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, {{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)

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

local areaid = addAreaName("my first area")
local newroomid = createRoomID()
addRoom(newroomid)
setRoomArea(newroomid, "my first area")
setRoomCoordinates(newroomid, 0, 0, 0)

local otherroomid = createRoomID()
addRoom(otherroomid)
setRoomArea(otherroomid, "my first area")
setRoomCoordinates(otherroomid, 0, 5, 0)

addSpecialExit(newroomid, otherroomid, "climb Rope")
addCustomLine(newroomid, {{4.5, 5.5, 3}, {4.5, 9.5, 3}, {6.0, 9.5, 3}}, "climb Rope", "dash dot dot line", {128, 128, 0}, false)

centerview(newroomid)

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

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

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.

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

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.
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
table {
  'northwest': 80
  'east': 78
}

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:
(Since TBA) 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.
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()
-- 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

mapSymbolFontInfo

mapSymbolFontInfo()
See also: setupMapSymbolFont()

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

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

moveMapLabel

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

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

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

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

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

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

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

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

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

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

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

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.

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 pathfinding. You can use the information to adjust your speedwalking path based on the door information in a room, though.
Doors CAN be set on stub exits - so that map makers can note if there is an obvious door to somewhere even if they do not (yet) know where it goes, perhaps because they do not yet have the key to open it!
Returns true if the change could be made, false if the input was valid but ineffective (door status was not changed), and nil with a message string on invalid input (value type errors).
See also: getDoors()
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. In versions prior to Mudlet 3.8, the symbol can be cleared by using "_" as the character. In Mudlet version 3.8 and higher, the symbol may be cleared with either a space " " or an empty string "".
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, "👿")
Since Mudlet version 3.8 : this facility 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()