Mapper

Available through the Scripts interface, the mapper API allows you to build areas of rooms with their linking exits into a data structure, and then display those rooms in a window, or on their own MXP frame.

The visible map can be interacted with via the mouse. Left-clicking a room will change the current or player room; and if done while holding cntrl or shift, will allow multi-room selection. Right-clicking brings up a context menu that will apply to either the room under the mouse, or a multi-room selection if applicable. You can also drag the flowing map window around by its title bar, or change your map view by dragging the visual area around.

The API listed below is almost entirely copped from Mudlet, and you can find their docs here. The differences between the two will be due to ignorance, or just a desire to add a bit more helpful. Here's an example of creating a map in an mxp frame using a Script:

win.process('<FRAME NAME=MAP ACTION=OPEN INTERNAL ALIGN=RIGHT WIDTH=25%>');
const map = win.mapper;
var areaId = map.addAreaName("Test Area");
var oareaId = map.addAreaName("The Other Test Area");
const areaIds = {0:areaId,1:oareaId};
const roomIds = {};

for(k in areaIds) {
    areaId = areaIds[k];
    for (let i = 0; i < 5; i++) {
        for (let j = 0; j < 5; j++) {
            let roomName = areaId+'_'+i+'_'+j;
            let roomId = map.addRoom(roomName, areaId);
            roomIds[roomName] = roomId; // Store the room ID
            map.setRoomCoordinates(roomId, i, j, 0);
            map.setRoomChar(roomId, ".");
            map.setRoomEnv(roomId, 1);
        }
    }
    for (let i = 0; i < 5; i++) {
        for (let j = 0; j < 5; j++) {
            let roomName = areaId+'_'+i+'_'+j;
            let roomId = roomIds[roomName];
            if (i < 4) {
                let eastRoomName = areaId+'_'+i+'_'+j;
                let eastRoomId = roomIds[eastRoomName];
                roomIds[eastRoomName] = eastRoomId; // Update roomIds
                map.setExit(roomId, eastRoomId, "east");
            }
            if (j < 4) {
                let southRoomName = areaId+'_'+i+'_'+j;
                let southRoomId = roomIds[southRoomName];
                roomIds[southRoomName] = southRoomId; // Update roomIds
                map.setExit(roomId, southRoomId, "south");
            }
        }
    }
}
map.centerview("1_0_0");
map.createMapper('MAP');
map.addMapMenu('testRoomMenu', 'room', 'Test Action');
map.addMapEvent('testRoomMenu', 'testFunction', 'room', 'Test Action', ['testArg']);

Mapper API Summary

addAreaName(areaName)
Adds a new area with the specified name, returning its ID.

addCustomLine(roomId, idOrTo, direction, style, color, arrow)
Draws a custom line from a room to another room ID or [x,y,z] coordinates. idOrTo can be a room ID or coordinate array.

addMapEvent(uniquename, eventName, parent, displayName, arguments)
Registers a custom event for a map menu item. arguments is an array of event parameters.

addMapMenu(uniquename, parent, displayName)
Adds a custom menu item to the map's context menu. parent can be 'room', 'label', 'empty', or another menu's uniquename.

addRoom(roomId, areaId)
Creates a new room in the specified area, returning its ID.

addSpecialExit(roomIdFrom, roomIdTo, moveCommand)
Adds a special exit with a custom move command between rooms.

auditAreas()
Checks areas for issues like missing names or rooms, returning a report.

autoLayout(areaId, startRoomId)
Automatically positions rooms in an area based on exits, optionally starting from startRoomId.

centerview(roomId)
Sets the map view to center on the specified room.

clearAreaUserData(areaId)
Removes all user data from the specified area.

clearAreaUserDataItem(areaId, key)
Deletes a specific user data key from the specified area.

clearMapSelection()
Clears all selected rooms on the map.

clearMapUserData()
Removes all user data from the map.

clearMapUserDataItem(key)
Deletes a specific user data key from the map.

clearRoomUserData(roomId)
Removes all user data from the specified room.

clearRoomUserDataItem(roomId, key)
Deletes a specific user data key from the specified room.

clearSpecialExits(roomId)
Removes all special exits from the specified room.

closeMapWidget()
Closes and destroys the map widget, cleaning up resources.

connectExitStub(fromId, toId, direction)
Links a room to another room or creates an exit stub. toId can be a room ID or direction if direction is undefined.

createMapLabel(areaId, text, posX, posY, posZ, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue, zoom, fontSize, showOnTop, noScaling, fontName, foregroundTransparency, backgroundTransparency, temporary)
Adds a text label to an area at specified coordinates with styling.

createMapImageLabel(areaId, filePath, posx, posy, posz, width, height, zoom, showOnTop, temporary)
Adds an image label to an area at specified coordinates.

createMapper(x, y, width, height)
Initializes the map widget. x can be a frame name (string) or x-coordinate (number).

createRoomId(minimumStartingRoomId)
Generates a unique room ID, optionally starting from minimumStartingRoomId.

createAreaId(minimumStartingAreaId)
Generates a unique area ID, optionally starting from minimumStartingAreaId.

deleteArea(areaId)
Removes an area and its rooms from the map. areaId can be ID or name.

deleteMapLabel(areaId, labelId)
Removes a specific label from an area.

deleteRoom(roomId)
Deletes one or more rooms and updates related exits. roomId can be a single ID or array.

disableMapInfo(label)
Disables map information display (not implemented).

enableMapInfo(label)
Enables map information display (not implemented).

findAreaId(areaName)
Locates an area by ID or name, returning its ID.

findRoomId(roomName)
Locates a room by ID or name, returning its ID.

confirmRoomId(roomId)
Verifies a room ID, resolving by name if needed.

exportAreaJson(areaId)
Exports the specified area to a JSON string.

exportAreaToUser(areaId, suggestedFileName)
Downloads the specified area as a JSON file.

getAllAreaUserData(areaId)
Returns all user data for the specified area.

getAllMapUserData()
Returns all user data for the map.

getAllRoomEntrances(roomId)
Lists all rooms with exits leading to the specified room.

getAllRoomUserData(roomId)
Returns all user data for one or more rooms. roomId can be a single ID or array.

getAreaExits(areaId, showExits)
Lists exits from an area to other areas, optionally with details if showExits is true.

getAreaRooms(areaId)
Returns a list of room IDs and names in the specified area.

getAreaRooms1(areaId)
Returns a sorted list of room IDs in the specified area.

getAreaCenterRoom(areaId)
Finds the room closest to the center of an area.

getAreaTable()
Returns a mapping of area names to their IDs.

getAreaTableSwap()
Returns a mapping of area IDs to their names.

getAreaUserData(areaId, key)
Retrieves a specific user data value for an area.

getCustomEnvColorTable()
Returns the custom environment color table.

getCustomLines(roomId)
Maps custom lines drawn from a room with their attributes.

getCustomLines1(roomId)
Alias for getCustomLines.

getDoors(roomId)
Lists doors in a room's exits with their status.

getExitStubs(roomId)
Lists direction numbers with unlinked exit stubs for a room.

getExitStubs1(roomId)
Alias for getExitStubs.

getExitWeights(roomId)
Returns weights for a room's exits.

getGridMode(areaId)
Checks if grid mode is enabled for an area.

getMapEvents()
Returns all custom map events.

getMapLabel(areaId, labelIdOrText)
Retrieves a label by ID or text from an area. labelIdOrText can be a label ID or text string.

getMapLabels(areaId)
Returns all labels in an area with their text or file paths.

getMapMenus()
Returns all custom map menu items.

getMapSelection()
Returns the list of currently selected rooms.

getMapUserData(key)
Retrieves a specific user data value for the map.

getMapZoom(areaId)
Returns the zoom level for the map or a specific area if areaId is provided.

getPath(fromId, toId)
Calculates the shortest path between two rooms, returning directions.

getPlayerRoom()
Returns the ID of the current player room (center view).

getRoomArea(roomId)
Returns the area ID of a room.

getRoomAreaName(roomId)
Returns the area name of a room.

getRoomChar(roomId)
Returns the display character for a room.

getRoomCharColor(roomId)
Returns the color of a room's display character.

getRoomCoordinates(roomId)
Returns the x, y, z coordinates of a room.

getRoomEnv(roomId)
Returns the environment ID of a room.

getRoomExits(roomId)
Lists a room's standard exits with their target room IDs.

getRoomHashById(roomId)
Returns the hash of a room by its ID.

getRoomIdbyHash(hash)
Returns the room ID associated with a hash.

getRoomName(roomId)
Returns the name of a room.

getRooms()
Returns a list of all room IDs and names.

getRoomsByPosition(areaId, x, y, z)
Lists rooms in an area at specific coordinates.

getRoomUserData(roomId, key)
Retrieves a specific user data value for a room.

getRoomUserDataKeys(roomId)
Returns all user data keys for a room.

getRoomWeight(roomId)
Returns the weight of a room for pathfinding.

getSpecialExits(roomId, listAllExits)
Lists special exits from a room with their commands, optionally including all if listAllExits is true.

getSpecialExitsSwap(roomId, listAllExits)
Lists special exits by command with their target rooms, optionally including all if listAllExits is true.

gotoRoom(roomId)
Navigates to a room by speedwalking along the shortest path.

getViewRoomId()
Returns the room id used for focusing the map view.

hasExitLock(roomId, direction)
Checks if a room's exit in a direction is locked.

hasSpecialExitLock(fromId, toId, moveCommand)
Checks if a special exit between rooms is locked.

highlightRoom(roomId, color1Red, color1Green, color1Blue, color2Red, color2Green, color2Blue, highlightRadius, color1Alpha, color2Alpha)
Highlights one or more rooms with custom colors and radius. roomId can be a single ID or array.

importAreaFromBrowser()
Prompts the user to select and import a JSON area file.

killMapInfo()
Terminates map information display (not implemented).

loadJsonMap(pathFileName)
Loads a map from a JSON file.

loadMap(pathFileName)
Alias for loadJsonMap.

lockExit(roomId, direction, lockIfTrue)
Locks or unlocks a room's exit in a direction.

lockRoom(roomId, lockIfTrue)
Locks or unlocks one or more rooms for pathfinding. roomId can be a single ID or array.

lockSpecialExit(fromId, toId, moveCommand, lockIfTrue)
Locks or unlocks a special exit between rooms.

moveMapWidget(Xpos, Ypos)
Repositions the map widget to new coordinates.

openMapWidget(Xpos, Ypos, width, height)
Opens the map widget with specified or saved parameters. Xpos can be a frame name or x-coordinate.

pauseSpeedwalk()
Pauses an ongoing speedwalk sequence.

recenterOnCurrent
Recenters the map view on the current player room.

registerMapInfo(label, func)
Registers a function for map information display (not implemented).

resumeSpeedwalk()
Resumes a paused speedwalk sequence.

removeCustomLine(roomId, direction)
Deletes a custom line from a room in a direction.

removeMapEvent(uniquename)
Removes a custom map event.

removeMapMenu(uniquename)
Removes a custom map menu item and its submenus.

removeSpecialExit(roomId, moveCommand)
Deletes a special exit from a room by move command.

resetRoomArea(roomId)
Clears the area ID of a room.

resizeMapWidget(width, height)
Resizes the map widget to new dimensions.

roomExists(roomId)
Checks if a room ID exists in the map.

roomLocked(roomId)
Checks if a room is locked for pathfinding.

saveJsonMap(pathFileName)
Saves the map to a JSON file.

saveMap(pathFileName)
Alias for saveJsonMap.

searchAreaUserData(key, value)
Searches areas for user data by key or value, returning matches.

searchRoom(roomId, caseSensitive, exactMatch)
Searches rooms by name, supporting case-sensitive or partial matches. roomId can be an ID or name string.

searchRoomUserData(key, value)
Searches rooms for user data by key or value, returning matches.

setAreaName(areaId, newName)
Sets or updates the name of an area. areaId can be ID or current name.

setAreaUserData(areaId, key, value)
Sets a user data key-value pair for an area.

setCustomEnvColor(environmentId, r, g, b, a)
Defines a custom environment color for a given ID.

setDoor(roomId, exitCommand, doorStatus)
Sets the door status (open, closed, locked) for a room's exit. exitCommand can be a direction or special command.

setExit(fromId, toId, direction)
Creates or updates a standard exit between rooms. toId < 0 removes the exit.

setExitStub(roomId, direction, set)
Adds or removes an unlinked exit stub in a direction.

setExitWeight(roomId, exitCommand, weight)
Sets the weight for a room's exit. exitCommand can be a direction or special command.

setGridMode(areaId, tf)
Enables or disables grid mode for an area.

setMapUserData(key, value)
Sets a user data key-value pair for the map.

setMapZoom(zoom, areaId)
Sets the zoom level for the map or a specific area if areaId is provided.

setRoomArea(roomId, areaId)
Sets the area for one or more rooms. areaId can be an ID or name; roomId can be a single ID or array.

setRoomChar(roomId, char)
Sets the display character for one or more rooms. roomId can be a single ID or array.

setRoomCharColor(roomId, color)
Sets the color of a room's display character. roomId can be a single ID or array.

setRoomCoordinates(roomId, x, y, z)
Sets the coordinates for one or more rooms. roomId can be a single ID or array.

setRoomEnv(roomId, envId)
Sets the environment ID for one or more rooms. roomId can be a single ID or array.

setRoomIdByHash(roomId, hash)
Associates a hash with a room ID.

setRoomName(roomId, name)
Sets the name for one or more rooms. roomId can be a single ID or array.

setRoomUserData(roomId, key, value)
Sets a user data key-value pair for one or more rooms. roomId can be a single ID or array.

setRoomWeight(roomId, weight)
Sets the weight for one or more rooms for pathfinding. roomId can be a single ID or array.

speedwalk(dirString, backwards, delay, show)
Executes a sequence of movement commands. dirString is a comma-separated list of directions.

stopSpeedwalk()
Stops an ongoing speedwalk sequence.

unHighlightRoom(roomId)
Removes highlighting from one or more rooms. roomId can be a single ID or array.

unsetRoomCharColor(roomId)
Clears the display character color for one or more rooms. roomId can be a single ID or array.

updateMap()
Redraws the map widget with current data.

viewArea(areaId)
Displays the given area on the map.