Open rmasoni opened 1 year ago
Another variant, with the selected targets and public chat for all players:
const tokens = canvas.tokens.controlled;
const rand = Math.floor(Math.random() * tokens.length);
const selected = tokens[rand];
const content = `
<p style="color:#007fff; font-weight: bold; font-size: 1rem;">Wheel of destiny. (Selected targets)</p> <i>${tokens.map(t => t.actor.name).join(", ")}.</i></p>
<p><strong>The randomy chosen one is:</strong> <h3>${selected.actor.name}</h3><p><img src="${selected.document.texture.src}" style="width: 50px; height: 50px; border: none;"></p>`;
await ChatMessage.create({content});
Credits to @Zhell and @Freeze on Discord Foundry VTT #macro-polo for the code and help.
I have only stylised it to make it look "prettier" in the chat.
For anyone that misses this module in v10, here's a macro that has the same basic functionality of displaying a random selected token on chat.
With the token image:
And without the token image:
Credits to Zhell#9201 on Discord for the code. I just styled the message and added the option with the token image.