history
This commit is contained in:
28
src/macro_stop-xp-history.js
Normal file
28
src/macro_stop-xp-history.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Stop XP history tracking for the configured actor.
|
||||
*/
|
||||
|
||||
const TARGET_ACTOR = game.actors.getName("Zeratal") ?? null;
|
||||
const ACTOR_ID = TARGET_ACTOR?.id ?? "put-actor-id-here";
|
||||
|
||||
if (!ACTOR_ID || ACTOR_ID === "put-actor-id-here") {
|
||||
return ui.notifications.warn("Set ACTOR_ID before running the macro.");
|
||||
}
|
||||
|
||||
const state = game.pf1?.xpHistory;
|
||||
if (!state) return ui.notifications.info("XP history tracking is not active.");
|
||||
|
||||
const logKey = `pf1-xp-history-${ACTOR_ID}`;
|
||||
const handler = state.hooks?.[logKey];
|
||||
|
||||
if (!handler) {
|
||||
return ui.notifications.info(`No XP history hook found for ${TARGET_ACTOR?.name ?? ACTOR_ID}.`);
|
||||
}
|
||||
|
||||
Hooks.off("updateActor", handler);
|
||||
delete state.hooks[logKey];
|
||||
state.sources?.delete(ACTOR_ID);
|
||||
if (state.current) delete state.current[ACTOR_ID];
|
||||
|
||||
const actorName = game.actors.get(ACTOR_ID)?.name ?? TARGET_ACTOR?.name ?? ACTOR_ID;
|
||||
ui.notifications.info(`XP history tracking disabled for ${actorName}.`);
|
||||
Reference in New Issue
Block a user