Client interface and DataCenter

Client information, window controls and DataCenter queries with queryData.

A separate client connection

mod.clientInterface connects Toolbox to its client-side component independently of the game packet stream. It provides process information, window controls and DataCenter queries. For a client module, ready signals interface readiness; it does not automatically guarantee that other modules' game data caches have finished loading.

Client information

mod.clientInterface.info contains:

Field Meaning
pid, arch Process ID and architecture (x64/ia32)
publisher, platform, environment Publisher, platform and environment
language DataCenter language
path Client folder path reported by the interface
majorPatchVersion, minorPatchVersion Patch components from ReleaseRevision
protocolVersion Protocol/DataCenter version used in C_CHECK_VERSION
protocol Packet name/opcode map
sysmsg System message name/ID map

Module shortcuts include mod.publisher, mod.platform, mod.environment, mod.language, mod.majorPatchVersion, mod.minorPatchVersion and mod.clientFolder. These describe the connected client, not the website language or system locale.

Window and camera

Method Purpose
flashWindow(count = 5, interval = 0, allowFocused = false) Flash the window/taskbar button; parameters are forwarded to the client
hasFocus() Promise resolving to whether the window has focus
configureCameraShake(enabled, power = 1.0, speed = 1.0) Enable/disable and configure camera shake
async function notifyIfInactive(mod) {
    try {
        if (!(await mod.clientInterface.hasFocus())) {
            mod.clientInterface.flashWindow();
        }
    } catch (error) {
        mod.error('Unable to query window focus:', error);
    }
}

queryData

mod.queryData(query, queryArgs = null, findAll = false, children = true, attributeFilter = null);

This aliases mod.clientInterface.queryData(...) and returns a Promise. findAll: true requests an array of nodes; otherwise a single result is requested. Nodes contain attributes and, when requested, children. Check for a result before accessing its properties.

A path such as /ItemData/Item@id=?/ selects nodes; @ introduces conditions and & combines them. Each ? takes the next value from queryArgs. Supported operators are =, !=, >, >=, <, <=. An array parameter with equality selects membership in a set; inequality excludes a set. This is the DataCenter query language, not JavaScript or SQL.

Query examples

// A creature name for the current client language.
const creature = await mod.queryData(
    '/StrSheet_Creature/HuntingZone@id=?/String@templateId=?',
    [huntingZoneId, templateId]
);
if (creature) mod.log(creature.attributes.name);

// Skill data with two conditions on the same node.
const skill = await mod.queryData(
    '/SkillData@huntingZoneId=?/Skill@templateId=?&id=?',
    [0, 16060, 10100]
);

// Item names, without child nodes.
const names = await mod.queryData('/StrSheet_Item/String/', [], true, false);
const itemNames = new Map(names.map((node) => [node.attributes.id, node.attributes.string]));

// Abnormality effects are child nodes.
const abnormality = await mod.queryData('/Abnormality/Abnormal@id=?/', [701420]);
if (abnormality) {
    for (const effect of abnormality.children) mod.log(effect.attributes);
}

// Hunting zones belonging to the current continent.
const zones = await mod.queryData(
    '/ContinentData/Continent@id=?/HuntingZone/', [mod.game.me.zone], true
);

// Comparisons and membership.
const ranked = await mod.queryData('/ItemData/Item@rank>=?/', [12], true, false);
const selected = await mod.queryData('/ItemData/Item@rank=?/', [[11, 12, 13]], true, false);

// Only the requested attributes, no children.
const items = await mod.queryData(
    '/ItemData/Item/', [], true, false, ['id', 'combatItemType']
);

Run these fragments inside an async function after client readiness. Table names, fields and IDs depend on the patch. Cache results for later network handlers instead of repeating queries for every packet.

Errors and performance

Handle Promise rejections with try/catch or .catch(...): malformed queries, invalid parameters or an unavailable interface must not leave unhandled errors. Do not fetch the entire SkillData tree for one skill. Queries allocate memory inside the game client; large trees are expensive for both 32-bit and 64-bit clients. Use children: false, attribute filters and caching. For common item and abnormality data, check mod.game.data first.

Sources: doc/mod/client-interface.md, node_modules/tera-client-interface/index.js, bin/mod.js.