Moerill / token-mold

MIT License
24 stars 33 forks source link

[BUG] Token name doesn't work on token when scene has large grid scale #123

Closed miromonti closed 1 year ago

miromonti commented 2 years ago

I happen to have a scene where a single grid square represents 45 feet. When I move a token on the scene, the name for the token does not change per Token Mold settings. However, the new TM name does end up on the token's character sheet.

https://user-images.githubusercontent.com/38819125/162149382-af3f6796-e3de-4218-928a-677ebf8ff2b5.mp4

Steps to reproduce the behavior:

  1. Assign large scale to scene grid.
  2. Move a token onto the scene.

Naturally, no one would make a grid so large for a typical token, so this is an edge case for sure. Still, the expectation (my expectation anyway) is that the token's new name would stick, regardless of grid scale.

I did test with Find the Culprit and this issue occurs with Token Mold active alone.

Geekswordsman commented 2 years ago

I've attempted to reproduce with your given steps on Foundry v9.266, however no matter how high I increase the grid scale, tokens still receive their names.

Are there any errors in the console when this happens?

Does this happen if Token Mold is the only module enabled?

miromonti commented 2 years ago

Turns out that there are errors, so this issue might be unique to me. But then, why?

Again, I set the game so only Token Mold is active and recorded these results:

https://user-images.githubusercontent.com/38819125/163660005-76f7e08a-9712-459a-9d7b-77538e0d7220.mp4

The scene is set the same as before: a grid square is 45 feet.

The obvious "Error: Invalid TokenData scale which must be a number between 0.2 and 10" is understandable, though I don't think it's involved with why Token Mold won't rename the tokens. Would it?

The rest is too coded for me, so I'll leave this console output here for you:

foundry.js:297

   Foundry VTT | Error thrown in hooked function '' for hook 'preCreateToken'

_call @ foundry.js:297 call @ foundry.js:279 _preCreateDocumentArray @ foundry.js:10013 await in _preCreateDocumentArray (async) _createEmbeddedDocuments @ foundry.js:9956 create @ backend.mjs:95 await in create (async) createDocuments @ document.mjs:338 create @ document.mjs:439 _onDropActorData @ foundry.js:31502 await in _onDropActorData (async) _onDrop @ foundry.js:21079 callback @ foundry.js:44539 _handleDrop @ foundry.js:44590 foundry.js:319

   Error: Invalid TokenData scale which must be a number between 0.2 and 10
at TokenData._validateField (data.mjs:384:13)
at TokenData.validate (data.mjs:275:14)
at TokenData.update (data.mjs:454:12)
at token-mold.js:260:18
at Function._call (foundry.js:294:14)
at Function.call (foundry.js:279:33)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:10013:47)
at async ClientDatabaseBackend._createEmbeddedDocuments (foundry.js:9956:22)

onError @ foundry.js:319 _call @ foundry.js:298 call @ foundry.js:279 _preCreateDocumentArray @ foundry.js:10013 await in _preCreateDocumentArray (async) _createEmbeddedDocuments @ foundry.js:9956 create @ backend.mjs:95 await in create (async) createDocuments @ document.mjs:338 create @ document.mjs:439 _onDropActorData @ foundry.js:31502 await in _onDropActorData (async) _onDrop @ foundry.js:21079 callback @ foundry.js:44539 _handleDrop @ foundry.js:44590 backend.mjs:306 Foundry VTT | Created Token with id [kQhuohSkQOQ0xcmw] in parent Scene [avDZGuNLzJgNmvgn] foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay foundry.js:297

   Foundry VTT | Error thrown in hooked function '' for hook 'preCreateToken'

_call @ foundry.js:297 call @ foundry.js:279 _preCreateDocumentArray @ foundry.js:10013 await in _preCreateDocumentArray (async) _createEmbeddedDocuments @ foundry.js:9956 create @ backend.mjs:95 await in create (async) createDocuments @ document.mjs:338 create @ document.mjs:439 _onDropActorData @ foundry.js:31502 await in _onDropActorData (async) _onDrop @ foundry.js:21079 callback @ foundry.js:44539 _handleDrop @ foundry.js:44590 foundry.js:319

   Error: Invalid TokenData scale which must be a number between 0.2 and 10
at TokenData._validateField (data.mjs:384:13)
at TokenData.validate (data.mjs:275:14)
at TokenData.update (data.mjs:454:12)
at token-mold.js:260:18
at Function._call (foundry.js:294:14)
at Function.call (foundry.js:279:33)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:10013:47)
at async ClientDatabaseBackend._createEmbeddedDocuments (foundry.js:9956:22)

onError @ foundry.js:319 _call @ foundry.js:298 call @ foundry.js:279 _preCreateDocumentArray @ foundry.js:10013 await in _preCreateDocumentArray (async) _createEmbeddedDocuments @ foundry.js:9956 create @ backend.mjs:95 await in create (async) createDocuments @ document.mjs:338 create @ document.mjs:439 _onDropActorData @ foundry.js:31502 await in _onDropActorData (async) _onDrop @ foundry.js:21079 callback @ foundry.js:44539 _handleDrop @ foundry.js:44590 backend.mjs:306 Foundry VTT | Created Token with id [Uo2BDEMzHAeMJspL] in parent Scene [avDZGuNLzJgNmvgn] foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay foundry.js:297

   Foundry VTT | Error thrown in hooked function '' for hook 'preCreateToken'

_call @ foundry.js:297 call @ foundry.js:279 _preCreateDocumentArray @ foundry.js:10013 await in _preCreateDocumentArray (async) _createEmbeddedDocuments @ foundry.js:9956 create @ backend.mjs:95 await in create (async) createDocuments @ document.mjs:338 create @ document.mjs:439 _onDropActorData @ foundry.js:31502 await in _onDropActorData (async) _onDrop @ foundry.js:21079 callback @ foundry.js:44539 _handleDrop @ foundry.js:44590 foundry.js:319

   Error: Invalid TokenData scale which must be a number between 0.2 and 10
at TokenData._validateField (data.mjs:384:13)
at TokenData.validate (data.mjs:275:14)
at TokenData.update (data.mjs:454:12)
at token-mold.js:260:18
at Function._call (foundry.js:294:14)
at Function.call (foundry.js:279:33)
at ClientDatabaseBackend._preCreateDocumentArray (foundry.js:10013:47)
at async ClientDatabaseBackend._createEmbeddedDocuments (foundry.js:9956:22)

onError @ foundry.js:319 _call @ foundry.js:298 call @ foundry.js:279 _preCreateDocumentArray @ foundry.js:10013 await in _preCreateDocumentArray (async) _createEmbeddedDocuments @ foundry.js:9956 create @ backend.mjs:95 await in create (async) createDocuments @ document.mjs:338 create @ document.mjs:439 _onDropActorData @ foundry.js:31502 await in _onDropActorData (async) _onDrop @ foundry.js:21079 callback @ foundry.js:44539 _handleDrop @ foundry.js:44590 backend.mjs:306 Foundry VTT | Created Token with id [gBhvSAh2ZIPc256J] in parent Scene [avDZGuNLzJgNmvgn] foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay foundry.js:3053 Foundry VTT | Rendering TokenMoldOverlay

What do you make of it?

Geekswordsman commented 2 years ago

Ah ha! Ok, I found where this is coming from!

I was testing on pf2e, which apparently has changed how the size information is stored and so my tests were actually completely bypassing where the scale was set!

There is indeed a bug here (well, two in fact!) Flagging it for fix on the next release, thanks for the updated information!