Open Galdormin opened 2 years ago
I updated the increment and decrement macros to:
if (!actor) {
ui.notifications.warn('Select a Clock before using this macro.');
}else if (actor.type != "🕛 clock") {
ui.notifications.warn('The selected token is not a Clock.');
}else{
const progress = actor.getFlag("lancer-clocks", "progress") + 1;
const size = actor.getFlag("lancer-clocks", "size");
const theme = actor.getFlag("lancer-clocks", "theme");
const imgLink = '/lancer-clocks/' + theme + '/' + size + 'clock_' + progress + '.png';
if(progress > size) {
ui.notifications.warn('The Clock is already filled.');
}else{
// Update Token
for (const t of actor.getActiveTokens()) {
await t.document.update({
name: actor.name,
img: imgLink,
actorLink: true,
light: {
animation: {
speed: Math.round(10 / size * progress),
type: "pulse"
}
}
});
}
// Update Actor
const updateData = {
['flags.lancer-clocks.progress']: progress,
img: imgLink,
token: {img: imgLink}
};
await actor.update(updateData);
}
}
if (!actor) {
ui.notifications.warn('Select a Clock to use this macro.');
}else if (actor.type != "🕛 clock") {
ui.notifications.warn('The selected token is not a Clock.');
}else{
const progress = actor.getFlag("lancer-clocks", "progress") - 1;
const size = actor.getFlag("lancer-clocks", "size");
const theme = actor.getFlag("lancer-clocks", "theme");
const imgLink = '/lancer-clocks/' + theme + '/' + size + 'clock_' + progress + '.png';
if(progress < 0) {
ui.notifications.warn('The Clock is already cleared.');
}else{
// Update Token
for (const t of actor.getActiveTokens()) {
await t.document.update({
name: actor.name,
img: imgLink,
actorLink: true,
light: {
animation: {
speed: Math.round( 10 / size * progress),
type: "pulse"
}
}
});
}
// Update Actor
const updateData = {
['flags.lancer-clocks.progress']: progress,
img: imgLink,
token: {img: imgLink}
};
await actor.update(updateData);
}
}
Hi, how do I use the macro? There seems to be an emoji in it and googling what "Actor.type" refers to in the Foundry API has yielded no results; what should this line be? How do I set the "type" an actor, or know an actor's type to know what to change the macro to?
Hi, here are some macros I use to easily create, increase and decrease the value of clocks.
New Clock Macro
Allows you to create a new clock. The lists
folders
,sizes
andthemes
are used to set the options for the clock creation. For folders, only the name should be used (even if it is a sub-folder).Increase Clock Value
Increase the value of a clock from its token. The value of the token, the actor and all other tokens are increased by 1.
Decrease Clock Value
Decrease the value of a clock from its token. The value of the token, the actor and all other tokens are decreased by 1.