59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
swadeMBHelpers.runOnTargetOrSelectedTokens(main)
|
|
|
|
async function main (tokens) {
|
|
const tokenList = tokens.map(t => t.name).join(', ')
|
|
const dialogOptions = {
|
|
title: 'Glow',
|
|
content: `Apply <em>Glow</em> to ${tokenList}`,
|
|
default: 'cancel',
|
|
buttons: [
|
|
{ label: 'OK', value: 'ok' },
|
|
{ label: 'Mutate token lighting', value: 'mutate' },
|
|
{ label: 'Cancel', value: 'cancel' }
|
|
]
|
|
}
|
|
|
|
const choice = await warpgate.buttonDialog(dialogOptions)
|
|
|
|
if (choice === 'ok' || choice === 'mutate') {
|
|
await createEffect(tokens, choice)
|
|
}
|
|
}
|
|
|
|
async function createEffect (tokens, choice) {
|
|
const icon = 'icons/magic/light/explosion-star-blue-large.webp'
|
|
const effectName = 'Glow'
|
|
for (const token of tokens) {
|
|
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
|
|
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
|
|
await warpgate.mutate(token.document, mutate, {}, mutateOptions)
|
|
if (choice === 'mutate') {
|
|
const mutate2 = {
|
|
token: {
|
|
light: {
|
|
alpha: 0.5,
|
|
angle: 360,
|
|
attenuation: 0.5,
|
|
animation: {
|
|
intensity: 5,
|
|
reverse: false,
|
|
speed: 5,
|
|
type: 'starlight'
|
|
},
|
|
bright: 0,
|
|
color: '#0f3fff',
|
|
coloration: 1,
|
|
contrast: 0,
|
|
dim: 0.5,
|
|
luminosity: 0.5,
|
|
saturation: 0,
|
|
shadows: 0
|
|
}
|
|
}
|
|
}
|
|
mutateOptions.permanent = false
|
|
await warpgate.mutate(token.document, mutate2, {}, mutateOptions)
|
|
}
|
|
}
|
|
}
|