token-mold
token-mold copied to clipboard
[BUG] tool incompatible with non-object attributes
Describe the bug The token mold module it seems like it cannot grab variables that are not in an object. IE if I am trying to get a "str" value stored as data:{abilities : {str:2}} it will work if I call "abilities .str" but if I have it stored as just data:{str:2} and I try to call "str" it will not find it.
To Reproduce Steps to reproduce the behavior: (this is how I found it other systems may or may not have similar issue)
- Install Expanse system in foundry (any age system will work fyi I am using my own https://github.com/tibeggs/expanse-edit ):
- Go to overlay and try to set an ability that is not organized as an object such as level. For example in expanse attributes are as follows data: { abilities: {Accuracy: 0, Communication: 2, etc.}, level: 1 }
- the abilities overlay will work but the level one will be empty
Expected behavior The overlay to be populated by the value.
Module incompatibilities not sure. I am doing this with only Token Mold.
Screenshots/GIFs/Videos If applicable, add screenshots to help explain your problem.
A picture is worth a thousand words.
Desktop (please complete the following information):
- OS: Windows 10
- Browser Foundry/Chrome
- FVTT Version 0.6.6
- Module version 2.10.1
Additional context By altering the copy of your module on my side I fixed the issue in a very ugly way. In scripts/overlay.js I changed getdata() to const data = super.getData(); // get properties and filter if property was not found data.stats = this.attrs.map(e => { try { var retdata = { icon: e.icon, path: e.path, value: getProperty(this.object.actor.data, e.path) }; } catch (err) { var retdata = { icon: e.icon, path: e.path.slice(0, -1), value: getProperty(this.object.actor.data, e.path.slice(0, -1)) }; } if (!retdata.value) { retdata = { icon: e.icon, path: e.path.slice(0, -1), value: getProperty(this.object.actor.data, e.path.slice(0, -1)) }; } const ret = retdata; if (ret.value === "" || ret.value === null || ret.value === undefined) return null; return ret; }).filter(e => e !== null); return data; }
The problem seemed to be path generating incomplete paths such as "data.armorRating." instead of "data.armorRating"
yep, the overlay is completly broken for that system.. :sweat_smile: At the time i created the overlay people all followed the DnD way of doing things so it was kinda safe back then.
I'll fix it, though the fix has to be at another place, i think, than in the getData method.
Ah and thanks for the very good issue and bug description!
https://github.com/Moerill/token-mold/issues/71 i would love to hear your thoughts on this. If i see it correctly this would kinda resolve your issue.
Unless it updated recently I believe token tool tip suffers from same issue. I personally do not like the side of token layout. I can check to see if they updated it later today.
I believe this issue should be resolved now in Foundry v10 with how it handles system data (forcing all system template information into an actual system object) - however, I will attempt to review and if it's not the case, see what can be done.