Initial commit

This commit is contained in:
Neill Cox 2024-05-03 20:27:39 +10:00
commit c983d9b91b
20 changed files with 5729 additions and 0 deletions

40
scripts/utils.js Normal file
View file

@ -0,0 +1,40 @@
import { MODULE } from './constants.js'
export let Utils = null
Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
/**
* Utility functions
*/
Utils = class Utils {
/**
* Get setting
* @param {string} key The key
* @param {string=null} defaultValue The default value
* @returns {string} The setting value
*/
static getSetting (key, defaultValue = null) {
let value = defaultValue ?? null
try {
value = game.settings.get(MODULE.ID, key)
} catch {
coreModule.api.Logger.debug(`Setting '${key}' not found`)
}
return value
}
/**
* Set setting
* @param {string} key The key
* @param {string} value The value
*/
static async setSetting (key, value) {
try {
value = await game.settings.set(MODULE.ID, key, value)
coreModule.api.Logger.debug(`Setting '${key}' set to '${value}'`)
} catch {
coreModule.api.Logger.debug(`Setting '${key}' not found`)
}
}
}
})