Skip to main content

State reference

nexMap.state is the read-only status surface — the nexMap4 successor to nexMap3's nexMap.status singleton. Reading it returns a fresh, frozen snapshot built from the live runtime. It is the nexMap-derived view, not a mirror of the host GMCP globals: consumers that want raw observed data already have GMCP.Room.Info and GMCP.Location.

const { location, pathing, path, tracking } = nexMap.state;

if (location.charted) {
console.log(`In ${location.area?.name}: ${location.room.name} (${location.roomId})`);
}

Top-level branches

BranchValueContents
state.locationobjectResolved player location (see below).
state.destinationnumber | nullTarget room id while a route is active, else null.
state.pathobject | nullThe active plan (commands, rooms, segments), or null when idle.
state.pathingbooleantrue while the walker is executing a plan.
state.trackingarrayCurrently tracked subjects (targets, pets, dopplegangers).

state.location

roomId and lastRoomId always reflect the observed movement stream. room and area are populated only when the current room is charted in the graph; for an uncharted room they are null and charted is false.

FieldValueMeaning
location.roomIdnumber | nullCurrent observed room id.
location.lastRoomIdnumber | nullPrevious distinct room — the one fact GMCP cannot supply.
location.chartedbooleanWhether the room exists in the runtime graph.
location.roomobject | null{ id, name, areaId, environment, indoors, x, y, z } when charted.
location.areaobject | null{ id, name, continent } when charted.

state.path

Present only while pathing is true:

FieldValueMeaning
path.commandsstring[]Raw movement/action commands for the route.
path.roomsnumber[]Ordered room ids along the route.
path.segmentsarrayPlan segments (per execution leg).

To compute a plan without executing it, use nexMap.api.travel.planRoute() instead — it returns the same shape plus totalWeight, sourceRoomId, and targetRoomId.

Serialization contract

The complete state tree is JSON-serializable and contains no function values:

const report = JSON.parse(JSON.stringify(nexMap.state));

This is the preferred shape for debug captures and bug reports. Snapshot objects are frozen; call a method under nexMap.api to request a change.

Fresh reads

A captured branch does not update in place — each read of nexMap.state produces a new snapshot. Re-read after a movement or pathing transition:

const before = nexMap.state.location;
// the player moves
const after = nexMap.state.location;

Use the event surfaces when an integration needs to know when to re-read.

Reading a room without moving there

nexMap.api.map.getNode(roomId) is a synchronous, in-memory read of a single graph node (exits, coordinates, environment, gameArea, …). It returns the canonical, frozen node record, or null when the room is uncharted. Treat it as read-only and re-read for fresh state rather than caching across moves.