Skip to content

Commit

Permalink
Merge pull request #321 from fermintxito/update_equip
Browse files Browse the repository at this point in the history
Update equip_unequip_shield.js
  • Loading branch information
AnthonyVadala committed Jul 4, 2022
2 parents 35fcb4e + 99d704d commit a7f85aa
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions misc/equip_unequip_shield.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ' <b>equips</b> their <i>' + ' ' + itemName+ '</i>');
chatMessage(actor.name + ' <b>equips</b> their <i>' + ' ' + itemName + '</i>');
} else {
chatMessage(actor.name + ' <b>un-equips</b> their <i>' + ' ' + itemName + '</i>');
chatMessage(actor.name + ' <b>un-equips</b> their <i>' + ' ' + itemName + '</i>');
}
}
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!");
}
Expand All @@ -55,4 +54,4 @@ function chatMessage(messageContent) {
};
ChatMessage.create(chatData, {});
}
}
}

0 comments on commit a7f85aa

Please sign in to comment.