Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getActorByName(actorName)
- {
- let actor = canvas.tokens.placeables.find(p => p.data.name === actorName)?.actor;
- if (!actor) actor = game.actors.entities.find(e => e.name === actorName);
- return actor;
- }
- let beastheartName = "REPLACE_beastheartActorName";
- let companionName = "REPLACE_companionActorName";
- let beastheart = getActorByName(beastheartName);
- let companion = getActorByName(companionName);
- let companionFerocity = companion.data.data.resources.primary.value;
- let beastheartFerocity = beastheart.data.data.resources.primary.value;
- let log = "";
- if(companionFerocity == beastheartFerocity)
- {
- log = `${beastheartName} and ${companionName}'s ferocity values are the same, so did nothing.`;
- }
- else if(companionFerocity > beastheartFerocity)
- {
- await beastheart.update({"data.resources.primary.value": companionFerocity});
- log = `Set ${beastheartName}'s ferocity to ${companionName}'s ferocity value of ${companionFerocity}.`;
- }
- else
- {
- await companion.update({"data.resources.primary.value": beastheartFerocity});
- log = `Set ${companionName}'s ferocity to ${beastheartName}'s ferocity value of ${companionFerocity}.`;
- }
- ChatMessage.create({
- user: game.user._id,
- speaker: ChatMessage.getSpeaker({token: actor}),
- content: log
- });
Add Comment
Please, Sign In to add comment