fix glow/shroud macros with optional mutation for lighting

This commit is contained in:
Mike Bloy 2023-03-04 23:34:38 -06:00
parent 58e2b033ae
commit 30b489e397
3 changed files with 71 additions and 57 deletions

View File

@ -8,24 +8,28 @@ async function main (tokens) {
default: 'cancel', default: 'cancel',
buttons: [ buttons: [
{ label: 'OK', value: 'ok' }, { label: 'OK', value: 'ok' },
{ label: 'Mutate token lighting', value: 'mutate' },
{ label: 'Cancel', value: 'cancel' } { label: 'Cancel', value: 'cancel' }
] ]
} }
const choice = await warpgate.buttonDialog(dialogOptions) const choice = await warpgate.buttonDialog(dialogOptions)
if (choice === 'ok') { if (choice === 'ok' || choice === 'mutate') {
await createEffect(tokens) await createEffect(tokens, choice)
} }
} }
async function createEffect (tokens) { async function createEffect (tokens, choice) {
const icon = 'icons/magic/light/explosion-star-blue-large.webp' const icon = 'icons/magic/light/explosion-star-blue-large.webp'
const effectName = 'Glow' const effectName = 'Glow'
for (const token of tokens) { for (const token of tokens) {
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, []) const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName) const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
mutate.token = { await warpgate.mutate(token.document, mutate, {}, mutateOptions)
if (choice === 'mutate') {
const mutate2 = {
token: {
light: { light: {
alpha: 0.5, alpha: 0.5,
angle: 360, angle: 360,
@ -46,6 +50,9 @@ async function createEffect (tokens) {
shadows: 0 shadows: 0
} }
} }
await warpgate.mutate(token.document, mutate, {}, mutateOptions) }
mutateOptions.permanent = false
await warpgate.mutate(token.document, mutate2, {}, mutateOptions)
}
} }
} }

View File

@ -8,24 +8,28 @@ async function main (tokens) {
default: 'cancel', default: 'cancel',
buttons: [ buttons: [
{ label: 'OK', value: 'ok' }, { label: 'OK', value: 'ok' },
{ label: 'Mutate token lighting', value: 'mutate' },
{ label: 'Cancel', value: 'cancel' } { label: 'Cancel', value: 'cancel' }
] ]
} }
const choice = await warpgate.buttonDialog(dialogOptions) const choice = await warpgate.buttonDialog(dialogOptions)
if (choice === 'ok') { if (choice === 'ok' || choice === 'mutate') {
await createEffect(tokens) await createEffect(tokens, choice)
} }
} }
async function createEffect (tokens) { async function createEffect (tokens, choice) {
const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp' const icon = 'icons/magic/perception/silhouette-stealth-shadow.webp'
const effectName = 'Shroud' const effectName = 'Shroud'
for (const token of tokens) { for (const token of tokens) {
const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, []) const mutate = swadeMBHelpers.createMutationWithEffect(icon, effectName, 5, [])
const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName) const mutateOptions = swadeMBHelpers.defaultMutationOptions(effectName)
mutate.token = { await warpgate.mutate(token.document, mutate, {}, mutateOptions)
if (choice === 'mutate') {
const mutate2 = {
token: {
light: { light: {
alpha: 0.5, alpha: 0.5,
angle: 360, angle: 360,
@ -46,6 +50,9 @@ async function createEffect (tokens) {
shadows: 0.25 shadows: 0.25
} }
} }
await warpgate.mutate(token.document, mutate, {}, mutateOptions) }
mutateOptions.permanent = false
await warpgate.mutate(token.document, mutate2, {}, mutateOptions)
}
} }
} }

File diff suppressed because one or more lines are too long