Repository navigation
API
const api = game.modules.get("dxcufgbs-initiative-tracker").api;
api.refresh(); // re-render the tracker and the turn-order numbers on tokens
await api.toggle(force); // show / hide the tracker for this user (force: true / false, or omit to flip) → new state
api.getOrder(combat); // the combatants this user can see, in initiative order (combat defaults to game.combat):
// [{combatantId, tokenId, sceneId, name, initiative, position, active, defeated}], position from 1;
// initiative is null for players
await api.resetLook(); // put this user's look settings back to the defaults
api.LOOK_DEFAULTS; // the default look settings (frozen object)The API is set during init, so it is ready from setup on.
For players, getOrder() follows the tracker: combatants hidden in the combat tracker (eye icon) are left out (a token only hidden on the map isn't), and in the first round hostile and neutral combatants only once their turn has come up.
Hooks.on("dxcufgbsInitiativeTrackerRender", (element, combat, context) => {
// after every render of the tracker on this client; element is the tracker's HTMLElement (#dxit-tracker)
});The API members, the hook, the setting ids and the element id dxit-tracker with its dxit-* classes don't change between versions.
Hooks.once("ready", () => {
const mod = game.modules.get("dxcufgbs-initiative-tracker");
if (!mod?.active) return;
console.log(mod.api.getOrder());
});Add { "id": "dxcufgbs-initiative-tracker", "type": "module" } to relationships.recommends in your module.json.
The module writes nothing to documents: only the user's own settings (for players also a hidden client setting remembering who has been revealed in each combat). Turn changes go through Foundry's own Combat methods.
Dxcufgb's Workshop: every Foundry VTT project, video and changelog in one place · Support on Ko-fi · MIT License
Using it
For the GM
For module authors
Help