29 lines
974 B
JavaScript
29 lines
974 B
JavaScript
/**
|
|
* Stop currency 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?.currencyHistory;
|
|
if (!state) return ui.notifications.info("Currency history tracking is not active.");
|
|
|
|
const logKey = `pf1-currency-history-${ACTOR_ID}`;
|
|
const handler = state.hooks?.[logKey];
|
|
|
|
if (!handler) {
|
|
return ui.notifications.info(`No currency 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(`Currency history tracking disabled for ${actorName}.`);
|