diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 26cc172..1c5ace9 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -3,6 +3,7 @@ import { Logger } from "../utils/Logger.mjs"; import { MemoryDatabase } from "../utils/databases/Memory.mjs"; import { registerCustomComponents } from "../Apps/elements/_index.mjs"; import { registerMetaSettings } from "../settings/meta.mjs"; +import { registerWorldSettings } from "../settings/world.mjs"; import { StatSidebar } from "../Apps/StatSidebar.mjs"; import { StatsViewer } from "../Apps/StatsViewer.mjs"; import { TableCreator } from "../Apps/TableCreator.mjs"; @@ -25,6 +26,7 @@ Hooks.on(`init`, () => { CONFIG.ui.sidebar.TABS.settings = temp; registerMetaSettings(); + registerWorldSettings(); CONFIG.stats = { db: UserFlagDatabase, diff --git a/module/hooks/preCreateChatMessage.mjs b/module/hooks/preCreateChatMessage.mjs index ed84645..44cb4ac 100644 --- a/module/hooks/preCreateChatMessage.mjs +++ b/module/hooks/preCreateChatMessage.mjs @@ -3,7 +3,8 @@ import { determinePrivacyFromRollMode } from "../utils/privacy.mjs"; Hooks.on(`preCreateChatMessage`, (_message, context, options, author) => { const isNew = options.action === `create`; const hasRolls = context.rolls?.length > 0; - if (!isNew || !hasRolls) { return }; + const autoTracking = game.settings.get(__ID__, `autoTrackRolls`); + if (!isNew || !hasRolls || !autoTracking) { return }; /** An object of dice denomination to rows to add */ const rows = {}; diff --git a/module/settings/world.mjs b/module/settings/world.mjs new file mode 100644 index 0000000..6da838c --- /dev/null +++ b/module/settings/world.mjs @@ -0,0 +1,18 @@ +/* +World Settings: + - Track rolls automatically + - Track inactive rolls (e.g. the "lower" in a "kh" roll) + - Track self rolls (defaulta false) +*/ + +export function registerWorldSettings() { + game.settings.register(__ID__, `autoTrackRolls`, { + name: `Roll Auto-Tracking`, + hint: `Whether or not the module should automatically add rolls made in the chat to the database. This is useful if the system you're using has implemented an integration with the module, or if you only want macros to handle the database additions.`, + scope: `world`, + type: Boolean, + config: true, + default: true, + requiresReload: true, + }); +};