macros/kalikke.js
This commit is contained in:
parent
0e7066608d
commit
93fa0caa29
53
macros/kalikke.js
Normal file
53
macros/kalikke.js
Normal file
@ -0,0 +1,53 @@
|
||||
const forms = [
|
||||
{
|
||||
token: 'modules/mb-pfsw-kingmaker/assets/tokens/npcs/companions/kanerah.Token.webp',
|
||||
avatar: 'modules/mb-pfsw-kingmaker/assets/tokens/npcs/companions/kanerah.Avatar.webp',
|
||||
name: 'Kanerah',
|
||||
formName: 'Kanerah Form',
|
||||
formItem: null,
|
||||
}, {
|
||||
token: 'modules/mb-pfsw-kingmaker/assets/tokens/npcs/companions/kalikke.Token.webp',
|
||||
avatar: 'modules/mb-pfsw-kingmaker/assets/tokens/npcs/companions/kalikke.Avatar.webp',
|
||||
name: 'Kalikke',
|
||||
formName: 'Kalikke Form',
|
||||
formItem: null
|
||||
}
|
||||
]
|
||||
const actorUUID = 'Actor.vfyKGZVNAuWnBPSU'
|
||||
|
||||
const EQUIPPED = CONFIG.SWADE.CONST.EQUIP_STATE.EQUIPPED
|
||||
const STORED = CONFIG.SWADE.CONST.EQUIP_STATE.STORED
|
||||
|
||||
async function main() {
|
||||
if (token.actor.uuid !== actorUUID) {
|
||||
ui.notifications.error("Incorrect token selected")
|
||||
return
|
||||
}
|
||||
|
||||
let activeForm = 0
|
||||
for (let idx = 0; idx < forms.length; idx++) {
|
||||
const form = forms[idx]
|
||||
form.formItem = token.actor.items.find(i => i.name === form.formName)
|
||||
if (form.formItem.system.equipStatus === EQUIPPED) {
|
||||
activeForm = idx
|
||||
}
|
||||
form.formItem.update({'system.equipStatus': STORED})
|
||||
}
|
||||
activeForm = (activeForm + 1) % forms.length
|
||||
|
||||
const itemMods = {'system.equipStatus': EQUIPPED}
|
||||
const tokenMods = {
|
||||
name: forms[activeForm].name,
|
||||
'texture.src': forms[activeForm].token
|
||||
}
|
||||
const actorMods = {
|
||||
name: forms[activeForm].name,
|
||||
img: forms[activeForm].avatar,
|
||||
}
|
||||
await token.document.update(tokenMods)
|
||||
await token.actor.update(actorMods)
|
||||
await forms[activeForm].formItem.update(itemMods)
|
||||
await token.actor.prototypeToken.update(tokenMods)
|
||||
}
|
||||
|
||||
main()
|
||||
Loading…
x
Reference in New Issue
Block a user