vtt-lair / token-replacer

Foundry VTT - Automatically replace NPC actor tokens and/or portraits dependent on token assets saved in a defined folder structure
MIT License
5 stars 4 forks source link

Does this not work on foundry [Release 0.8.9]? #79

Closed ZcytheGaming closed 2 years ago

ZcytheGaming commented 2 years ago

I'm 99% sure I got all my settings right... Links go to IMGUR

Folder Structure

Filename Format

System Settings

Structure Settings

Formatting Settings

ZcytheGaming commented 2 years ago

But it doesnt change the token artwork :(

vtt-lair commented 2 years ago

Settings look correct.

This could be due to the "1/2", "1/4" and "1/8" that Forgotten Adventures used with their old CR system. Windows does not actually allow "/" in folder and file names. Further to that, Foundry use the decimal value for those CR's.

As a first fix, rename those 3 folders to: "CR_0_5", "CR_0_25", and "CR_0_125".

After changing those folder names, do a refresh (F5) so that the folders are re-cached and check if it works.

If it still doesn't work after that, press F12, click on Console: image

click on the "clear button": image

And keeping the console open, drag an NPC actor to the scene and let's see if there's an error logged.

ZcytheGaming commented 2 years ago

Made the changes, and got this with debug on,

Token Replacer: createActorHook: Data: 
Object { overrides: {}, _preparationWarnings: [], armor: null, shield: null, _classes: undefined, labels: {…}, apps: {}, _sheet: {…}, _tokenImages: null, _lastWildcard: null, … }
token-replacer.js:384:21
Token Replacer: Replacing Artwork token-replacer.js:473:21
Token Replacer: searching for token for tokens/creatures/cr_0_25/wolf token-replacer.js:505:21
Token Replacer: searching for portrait for tokens/creatures/cr_0_25/wolf token-replacer.js:506:21
Token Replacer: Found these tokens: token-replacer.js:517:21
Token Replacer: Found these portraits: tokens/Creatures/CR_0_25/Wolf_Medium_Beast_01.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_02.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_03.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_04.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_05.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_06.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_07.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_08.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_09.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_10.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_11.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_12.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_13.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_14.png token-replacer.js:518:21
Foundry VTT | Created Actor with id [oObyb4Y3Blc2acCJ] backend.mjs:306:18
Token Replacer: preCreateTokenHook: Before: TokenData: 
Object { _id: null, name: "Wolf", displayName: 0, actorId: "oObyb4Y3Blc2acCJ", actorLink: false, actorData: {}, img: "DDBImages/npc-token-Wolf.jpeg", tint: null, width: 1, height: 1, … }
token-replacer.js:415:21
Token Replacer: preCreateTokenHook: Before: Actor: 
Object { overrides: {}, _preparationWarnings: [], armor: null, shield: null, _classes: undefined, labels: {…}, apps: {}, _sheet: {…}, _tokenImages: null, _lastWildcard: null, … }
token-replacer.js:416:21
Token Replacer: preCreateTokenHook: Before: PassData: 
Object { _id: "oObyb4Y3Blc2acCJ", name: "Wolf", type: "npc", img: "https://media-waterdeep.cursecdn.com/avatars/70/296/636463321440362758.png", data: {…}, token: {…}, items: Map(3), effects: Map(0), folder: null, sort: 0, … }
token-replacer.js:421:25
Token Replacer: Replacing Artwork token-replacer.js:473:21
Token Replacer: searching for token for tokens/creatures/cr_0_25/wolf token-replacer.js:505:21
Token Replacer: searching for portrait for tokens/creatures/cr_0_25/wolf token-replacer.js:506:21
Token Replacer: Found these tokens: token-replacer.js:517:21
Token Replacer: Found these portraits: tokens/Creatures/CR_0_25/Wolf_Medium_Beast_01.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_02.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_03.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_04.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_05.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_06.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_07.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_08.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_09.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_10.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_11.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_12.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_13.png,tokens/Creatures/CR_0_25/Wolf_Medium_Beast_14.png token-replacer.js:518:21
Token Replacer: preCreateTokenHook: After: TokenData: 
Object { _id: null, name: "Wolf", displayName: 0, actorId: "oObyb4Y3Blc2acCJ", actorLink: false, actorData: {}, img: "DDBImages/npc-token-Wolf.jpeg", tint: null, width: 1, height: 1, … }
token-replacer.js:439:25
Token Replacer: preCreateTokenHook: After: Actor: 
Object { overrides: {}, _preparationWarnings: [], armor: null, shield: null, _classes: undefined, labels: {…}, apps: {}, _sheet: {…}, _tokenImages: null, _lastWildcard: null, … }
token-replacer.js:440:25
Token Replacer: preCreateTokenHook: After: PassData: 
Object { _id: "oObyb4Y3Blc2acCJ", name: "Wolf", type: "npc", img: "https://media-waterdeep.cursecdn.com/avatars/70/296/636463321440362758.png", data: {…}, token: {…}, items: Map(3), effects: Map(0), folder: null, sort: 0, … }
token-replacer.js:441:25
Mapping tokens pathPatroller.js:232:17
Mapping Paths pathPatroller.js:245:17
about-face |  createTokenHandler, creating TokenIndicator for: Wolf logging.js:28:17
Token Replacer: createTokenHook: Before: TokenData: 
Object { _id: "b2dtAB5ADhYluBO3", name: "Wolf", displayName: 0, actorId: "oObyb4Y3Blc2acCJ", actorLink: false, actorData: {}, img: "DDBImages/npc-token-Wolf.jpeg", tint: null, width: 1, height: 1, … }
token-replacer.js:455:21
Token Replacer: createTokenHook: Before: Actor: 
Object { overrides: {}, _preparationWarnings: [], armor: null, shield: null, _classes: undefined, labels: {…}, apps: {}, _sheet: {…}, _tokenImages: null, _lastWildcard: null, … }
token-replacer.js:456:21
You are calling PlaceableObject#update which has been deprecated in favor of Document#update or Scene#updateEmbeddedDocuments. Support will be removed in 0.9.0 foundry.js:19457:13
Token Replacer: createTokenHook: After: TokenData: 
Object { _id: "b2dtAB5ADhYluBO3", name: "Wolf", displayName: 0, actorId: "oObyb4Y3Blc2acCJ", actorLink: false, actorData: {}, img: "DDBImages/npc-token-Wolf.jpeg", tint: null, width: 1, height: 1, … }
token-replacer.js:464:25
Token Replacer: createTokenHook: After: Actor: 
Object { overrides: {}, _preparationWarnings: [], armor: null, shield: null, _classes: undefined, labels: {…}, apps: {}, _sheet: {…}, _tokenImages: null, _lastWildcard: null, … }
token-replacer.js:465:25
Foundry VTT | Created Token with id [b2dtAB5ADhYluBO3] in parent Scene [5dlTHbsMseZPDvqA] backend.mjs:306:18
Some cookies are misusing the recommended “SameSite“ attribute 2

Looks like it sees the files but isn't applying the change?

ZcytheGaming commented 2 years ago

only error [highlighted] is You are calling PlaceableObject#update which has been deprecated in favor of Document#update or Scene#updateEmbeddedDocuments. Support will be removed in 0.9.0

vtt-lair commented 2 years ago

Thanks for the debug logs, looking at the logs I think I found the issue. You have the "Portrait Prefix" on the Formatting tab set as empty and that seems to be causing the images to be set to portraits instead of tokens:

image

Can you please try and set a value for the Portrait Prefix to have an actual value and see if that sorts out the issue?

holding thumbs & crossing my fingers

vtt-lair commented 2 years ago

Yes can confirm that is the issue. I removed the prefix from my own settings and experienced the same issue: image

Adding a prefix fixed that: image

So just adding a prefix value to identify portraits, even if you aren't replacing portraits will fix this issue. Will fix this with the next release.

vtt-lair commented 2 years ago

@ZcytheGaming I've released the fix for this so the work around isn't needed. Released with 0.6.0