31 lines
922 B
JavaScript
31 lines
922 B
JavaScript
import { api } from './api.js'
|
|
import { requestTokenRoll } from './helpers.js'
|
|
import { shapeChangeOnDismiss } from './powerEffects.js'
|
|
import { log, shim } from './shim.js'
|
|
|
|
const moduleName = 'swade-mb-helpers'
|
|
|
|
function _checkModule (name) {
|
|
if (!game.modules.get(name)?.active && game.user.isGM) {
|
|
let action = 'install and activate'
|
|
if (game.modules.get(name)) action = 'activate'
|
|
ui.notifications.error(
|
|
`SWADE MB Helpers requires the ${name} module. Please ${action} it.`)
|
|
}
|
|
}
|
|
|
|
Hooks.on('setup', api.registerFunctions)
|
|
|
|
Hooks.on('ready', () => {
|
|
_checkModule('warpgate')
|
|
_checkModule('socketlib')
|
|
log('Initialized SWADE MB Helpers')
|
|
warpgate.event.watch(warpgate.EVENT.DISMISS, shapeChangeOnDismiss)
|
|
})
|
|
|
|
Hooks.on('socketlib.ready', () => {
|
|
const socket = socketlib.registerModule('swade-mb-helpers')
|
|
socket.register('requestTokenRoll', requestTokenRoll)
|
|
shim._socket = socket
|
|
})
|