diff --git a/misc/equip_unequip_shield.js b/misc/equip_unequip_shield.js index bfd7920..8978c2c 100644 --- a/misc/equip_unequip_shield.js +++ b/misc/equip_unequip_shield.js @@ -14,32 +14,31 @@ const effectIconPath = 'icons/svg/shield.svg'; // <--- Add the effect icon you w let toggleResult = false; if (!actor) { - ui.notifications.warn('You need to select a token before using this macro!'); + ui.notifications.warn('You need to select a token before using this macro!'); } else { const myItem = actor.items.getName(itemName); - if (myItem) - { + if (myItem) { let item = actor.items.get(myItem.id); let attr = "data.equipped"; let equipped = getProperty(item.data, attr); - if (sendToChat) { + if (sendToChat) { if (!equipped) { - chatMessage(actor.name + ' equips their ' + ' ' + itemName+ ''); + chatMessage(actor.name + ' equips their ' + ' ' + itemName + ''); } else { - chatMessage(actor.name + ' un-equips their ' + ' ' + itemName + ''); + chatMessage(actor.name + ' un-equips their ' + ' ' + itemName + ''); } } - item.update({[attr]: !getProperty(item.data, attr)}); - + item.update({ [attr]: !getProperty(item.data, attr) }); + // mark/unmark character's token with an effect icon when displayToken is true - (async () => { + (async () => { if (displayIcon) { - toggleResult = await token.toggleEffect(effectIconPath); - if (toggleResult == equipped) token.toggleEffect(effectIconPath); + toggleResult = await token.toggleEffect(effectIconPath, { active: !equipped }); + // if (toggleResult == equipped) token.toggleEffect(effectIconPath, {active: equipped}); } })(); - + } else { ui.notifications.warn("No item named '" + itemName + "' found on character!"); } @@ -55,4 +54,4 @@ function chatMessage(messageContent) { }; ChatMessage.create(chatData, {}); } -} +} \ No newline at end of file