Initial commit
This commit is contained in:
commit
03761d2e2f
17 changed files with 5662 additions and 0 deletions
40
scripts/utils.js
Normal file
40
scripts/utils.js
Normal 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`)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue