Aedif / TokenVariants

GNU General Public License v3.0
17 stars 12 forks source link

Allow manual re-caching of folders #19

Closed TiloBuechsenschuss closed 3 years ago

TiloBuechsenschuss commented 3 years ago

It would be very useful if there was a button (or a macro) that would trigger re-caching of the set paths. So you don't have to reload the game or manually switch caching on if you added a few images or a new path.

Aedif commented 3 years ago

Hmm, if I understand you correctly you already know that re-caching can be done by toggling the 'Disable Caching' setting on and off, but would like a way to do the same outside of the settings window?

Assuming above is correct I could expose the caching function for this module so that it can be called in a macro. Will respond under this issue again once I get this done, should be ready at some point today.

TiloBuechsenschuss commented 3 years ago

Hmm, if I understand you correctly you already know that re-caching can be done by toggling the 'Disable Caching' setting on and off, but would like a way to do the same outside of the settings window?

Yeah, exactly. Going to the settings and hunting for the option is somewhat unwieldy. Having a dedicated button somewhere or an API call you can put in a macro would be much quicker options (at least in my workflow).

Thanks for thinking about adding that! :-) 👍

Aedif commented 3 years ago

The functionis now exposed and can be used in macros through game.TokenVariants.cacheTokens() as of release 1.12.0

This is an async function that may take a few seconds to fully execute depending on how many folders and art it needs to scan through.

TiloBuechsenschuss commented 2 years ago

Just wanted to leave you a note: works great for me, makes dropping in a new token art (from Tokenstamp) a breeze. Thanks a bunch! :-)

For all interested in a quick and dirty macro - here you go:

let refresh = async function () { let returnValue = game.TokenVariants.cacheTokens(); return returnValue; }; refresh().then( (value) => { ChatMessage.create( { content: 'Token Variant Art re-cached.' }, {}, ); } );