Skip to main content

API reference

Functions are grouped by domain under nexGui.api. Data snapshots live under nexGui.state; api holds only behavior.

Namespaces​

NamespacePurposeRepresentative methods
api.characterCharacter class checksclass.get, class.is
api.targetCurrent combat targetget, set, is
api.playersPlayer directory queriesget, color, fetch, qwFormat
api.displayDisplay helpers (alias api.colors)playerColor, iconHtml, notice
api.timersTimer barsadd, start, stop, reset, remove, clear, get, list
api.customizeConfigured defences, class balance, native displaydefences.set, classBalance.set, nativeDisplay.mount
api.layoutNamed layout templateslist, has, save, apply, remove
api.partyParty membershipisMember
api.roomRoom display overrides and text replacementsitems.set, npcs.set, replacements.set
api.streamSystem / Combat side streamsadd
api.cdbCharacter databasequery, get

Verb conventions​

VerbMeaning
getSynchronous parameterized in-memory read. Bare reads live in state.
setFull overwrite of a scalar or collection.
fetch / queryAsynchronous read that may hit the network.
add / remove / clearMutate a collection.
listEnumerate a collection, usually with filters.
start / stop / resetImperative lifecycle on a named entity.
mount / unmountReact or host UI lifecycle commands.
is*Boolean predicate.

nexGui.api.character​

MethodReturnsNotes
class.get()stringCurrent class label.
class.is(value)booleanCase-insensitive class predicate.

nexGui.api.target​

MethodReturnsNotes
get(){ id, name, isPlayer }Current two-field target identity.
set(value)string | nullDrives the host settarget; state reconciles when GMCP echoes the target identity.
is(value)booleanCase-insensitive match against the current target id or name.

nexGui.api.players​

MethodReturnsNotes
get(name)object | nullSynchronous in-memory profile lookup.
color(name)stringPlayer display color.
fetch(name)Promise<object | null>Forces a refresh, updates the directory cache, returns the profile.
qwFormat(entries, options)stringRenders a captured Quick-Who list as a city-grouped table, paints it to the game window, and returns the HTML.

Directory enumeration lives at nexGui.state.players.directory.

qwFormat accepts an array of bare names ("Logan") or { name, city } records — pass the live Quick-Who city so grouping stays correct before any async fetch lands. options.totalLine overrides the computed footer.

nexGui.api.display​

Also exposed as nexGui.api.colors (same object).

MethodReturnsNotes
playerColor(name)stringPlayer display color (same resolver as api.players.color).
iconHtml(id, colors, size)stringRenders a dual-tone Font Awesome icon to trusted HTML.
notice(message, options)voidWrites a host notice line.

The city palette lives at nexGui.state.players.cityPalette.

nexGui.api.timers​

MethodReturnsNotes
add(id, durationMs, label, options)object | nullCreates or replaces a timer.
start(id)object | nullStarts an existing timer.
stop(id)object | nullStops an existing timer.
reset(id)object | nullResets an existing timer.
remove(id)object | nullRemoves a timer.
clear(filters)numberClears all timers, or timers matching groupId. Returns the count cleared.
get(id)object | nullParameterized timer lookup.
list(filters)object[]Filtered enumeration. Requires a filter; use state.timers.list for the unfiltered snapshot.

add options:

OptionValuesNotes
autoStartbooleanDefaults to false (created dormant). Set true to start immediately.
direction"countdown" | "countup"Countdown drains full→empty; count-up fills empty→full.
position"top" | "bottom"Timer stack placement.
stayVisiblebooleanDefaults to true. Set false to show only while running.
groupId / groupIdsstring | string[]Group metadata for filtered list / clear.

nexGui.api.customize​

MethodReturnsNotes
defences.set(value)string[]Replaces the configured defence checklist. Read from state.customize.defences.
classBalance.set(value)string | nullReplaces the class-balance stat label. Read from state.customize.classBalance.
nativeDisplay.mount()voidMounts the display into the host output area.
nativeDisplay.unmount()voidRestores the host's default output area.

nexGui.api.layout​

Named layout templates, persisted in the layouts slice of nexGui4Settings. The kDesktop and mobile starters are seeded into the collection on first run and are ordinary entries afterwards — overwritable and deletable.

Every method also announces its outcome as a nexGui notice, so aliases wired straight to these calls give the player feedback without reading the return value. Failures (missing name, unknown layout, full store) are noticed in red.

MethodReturnsNotes
list()string[]Stored layout names, in insertion order.
has(name)booleanWhether a layout is stored under name.
save(name)booleanSnapshots the live layout, overwriting a same-named entry. false for a blank name or when the 20-layout limit is reached.
apply(name)booleanApplies a stored layout. false when nothing matches name.
remove(name)booleanDeletes a stored layout. false when none existed.

nexGui.api.party​

MethodReturnsNotes
isMember(name)booleanCase-insensitive party-membership predicate.

Party data lives at nexGui.state.party.

nexGui.api.room​

MethodReturnsNotes
items.set(name, override)object | nullSets a display override (text, color, background) for a room item. Returns the normalized override, or null if empty.
items.remove(name)voidRemoves an item override.
items.get(name)object | nullReads an item override.
items.list()object[]Lists { name, override } records.
npcs.set(nameOrId, override)object | nullSets a display override (text, color, background, idColor, nameColor) for an NPC row. Numeric ids and names are both valid keys. color styles the displayed NPC name; nameColor can override it when both are supplied.
npcs.remove(nameOrId)voidRemoves an NPC override.
npcs.get(nameOrId)object | nullReads an NPC override.
npcs.list()object[]Lists { name, override } records.
replacements.set(id, rule)object | nullRegisters a room-description replacement rule. Requires pattern: RegExp and exactly one renderer: html, text, marker, or segments.
replacements.remove(id)voidRemoves a user room-description replacement. Removing a same-id override restores the built-in rule.
replacements.get(id)object | nullReads a user replacement descriptor.
replacements.list()object[]Lists user replacement { id, descriptor } records.

Room text replacement renderers are declarative. html is trusted raw HTML; text and segments are escaped by nexGui. Callback renderers receive { id, match, captures, groups, index, input }.

nexGui.api.room.replacements.set("boulder", {
gate: "granite boulder",
pattern: /A granite boulder sits cracked upon the ground\./g,
html: () =>
`<span style="color: tomato">BOULDER! </span><span style="color: red">DANGER!!</span>`,
});

nexGui.api.stream​

MethodReturnsNotes
add({ html, stream })object | nullAppends trusted HTML to the "system" or "combat" side stream. Throws on a missing html or an unknown stream.

See the Side streams guide. Stream transcripts are not part of nexGui.state.

nexGui.api.cdb​

MethodReturnsNotes
query(filter)Promise<object[]>Filtered query against the stored character database. A missing / empty filter resolves to [] without a network call.
get(name)Promise<object | null>Live lookup against the Achaea public character API (bypasses the stored database).

Return values​

Predicate methods return booleans. Lookup methods may return null when an id is unknown. Mutation methods commonly return the resulting value or null. set(value) on the target drives a host command and reconciles asynchronously when GMCP echoes the change — observe the confirmed result through nexGui.state.