Moerill / token-mold

MIT License
27 stars 33 forks source link

World function for resetting names to be used in macros #37

Open CarnivorousM opened 4 years ago

CarnivorousM commented 4 years ago

Is there a macro or something I can drop on the hotbar that recreates the function of 1)going to the actor tab 2)opening Token Mold cog 3)going to Name tab 4)clicking on 'Reset counter for this scene for all tokens'?

On larger maps, if there are more than 1 grouping of tokens in an area - I prefer to have each area reset the numbers (just in case the come in the rear and see 'Baddie (35)' as the first guy and playing it safer since they now can see a dumpload of baddies. It's just a lot of opening it up to reset / closing or shrinking it to do map work / reopening it to trigger it / wash-rinse-repeat.

Was basically wondering if there was a quick-click to reset the counter (from a macro or other hotbar item)?

Moerill commented 4 years ago

There is currently no real macro option for that. what you could do though is replicate thet code used to reset inside a script macro:

const tm = game["token-mold"];
const sceneId  = canvas.scene.id;

tm.counter[sceneId] = {};
const tokens = canvas.scene.getEmbeddedCollection('Token');

for (const token of tokens)
  if (token.actorId)
    tm.counter[sceneId][token.actorId] = 0;

ui.notifications.notify('Finished resetting counters');

its untested and only quickly copy pasted and tried to adapt, so test it at some save environment

Moerill commented 4 years ago

also maybe when i got some time to go back to work on modules i'll consider providing some sort of easier macro method here.

CarnivorousM commented 4 years ago

image

Fresh world: (only TM active) I copied that into a macro and them created 3 tokens, then attempted to activate the macro twice. I don't really understand it well enough to know better (just enough to know - I don't know).

The red bar popup simply says "There was an error in your macro syntax. See console (f12) for details." (image attached of console) Things are functional for what I need. It's not game-breaking. When you get time. Thanks for even getting back.

Moerill commented 4 years ago

there was a missing "." in line 9. Added it should fix at least that error.

CarnivorousM commented 4 years ago

They did it. This is great! Thanks.