From 99d704d01f8778f37e6a8c64ba690c5b6eb3aa82 Mon Sep 17 00:00:00 2001 From: Fermin Gorraiz Date: Sat, 25 Jun 2022 11:43:55 +0200 Subject: [PATCH] Update equip_unequip_shield.js --- misc/equip_unequip_shield.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) 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