bmarian / token-tooltip-alt

A module that adds a tooltip next to the currently hovered token to show some useful information for players and DMs.
MIT License
9 stars 15 forks source link

[BUG] Exception when referencing string property in expression #64

Closed RayakiTheTurtle closed 3 years ago

RayakiTheTurtle commented 3 years ago

Describe the bug When referencing a string value in an expression, an exception gets thrown. If just the string value is used as a non-expression, the value displays without any issues.

To Reproduce Steps to reproduce the behavior:

  1. Create new world with DND5e system, install and activate Module.
  2. Open Tooltip Editor.
  3. Put { s=<attributes.spellcasting>;s } as the value, tick Exp.
  4. Save configuration.
  5. Hover over token in scene.
  6. Console throws exception Error: Undefined symbol cha.

Screenshots 2020-12-18 18_28_16-Window

Please complete the following information:

Additional context This error seems to happen with any string property. When just put input as plain value, with the Exp checkbox off, the value displays without issue.

An export of your tooltip settings Please provide an export of your settings, found by going into the Tooltip manger and clicking Export.

{"gmSettings":{"default":{"items":[{"disposition":"FRIENDLY","items":[{"value":"attributes.hp.value","icon":"","expression":false,"isNumber":false,"color":"#5d6ed0"}]},{"disposition":"NEUTRAL","items":[{"value":"attributes.hp.value","icon":"","expression":false,"isNumber":false,"color":"#7f5f7a"}]},{"disposition":"HOSTILE","items":[{"value":"attributes.hp.value","icon":"","expression":false,"isNumber":false,"color":"#b6cb82"}]}],"static":{"displayNameInTooltip":true,"useAccentEverywhere":false,"accentColor":"#52f054","tokenDispositions":["FRIENDLY","NEUTRAL","HOSTILE"],"useAccentColorForEverything":false}},"character":{"items":[{"disposition":"FRIENDLY","items":[{"value":"{ s=<attributes.spellcasting>;s}","icon":"","expression":true,"isNumber":false,"color":"#860f7b"}]},{"disposition":"NEUTRAL","items":[]},{"disposition":"HOSTILE","items":[]}],"static":{"displayNameInTooltip":false,"useAccentEverywhere":false,"accentColor":"#000000","tokenDispositions":["FRIENDLY","NEUTRAL","HOSTILE"],"useAccentColorForEverything":false}},"npc":{"items":[{"disposition":"FRIENDLY","items":[]},{"disposition":"NEUTRAL","items":[]},{"disposition":"HOSTILE","items":[]}],"static":{"displayNameInTooltip":true,"accentColor":"#eb3caa","useAccentColorForEverything":false,"tokenDispositions":["FRIENDLY","NEUTRAL","HOSTILE"]}},"vehicle":{"items":[{"disposition":"FRIENDLY","items":[]},{"disposition":"NEUTRAL","items":[]},{"disposition":"HOSTILE","items":[]}],"static":{"displayNameInTooltip":true,"accentColor":"#9b21eb","useAccentColorForEverything":false,"tokenDispositions":["FRIENDLY","NEUTRAL","HOSTILE"]}}},"playerSettings":{"default":{"items":[{"disposition":"OWNED","items":[]},{"disposition":"FRIENDLY","items":[{"value":"attributes.hp.value","icon":"","expression":false,"isNumber":false,"color":"#83eba1"}]},{"disposition":"NEUTRAL","items":[{"value":"attributes.hp.value","icon":"","expression":false,"isNumber":false,"color":"#fad4b5"}]},{"disposition":"HOSTILE","items":[{"value":"attributes.hp.value","icon":"","expression":false,"isNumber":false,"color":"#5bf969"}]}],"static":{"displayNameInTooltip":"FRIENDLY","useAccentEverywhere":false,"accentColor":"#c3002f","tokenDispositions":["OWNED","FRIENDLY","NEUTRAL","HOSTILE"],"useAccentColorForEverything":false}},"character":{"items":[{"disposition":"OWNED","items":[]},{"disposition":"FRIENDLY","items":[{"value":"{ hp=<attributes.hp.value>; hpm=<attributes.hp.max>; hpt=<attributes.hp.temp>; hptm=<attributes.hp.tempmax>; hpt=compareText(typeOf(hpt), \"null\") == 0 ? 0 : hpt; hptm=compareText(typeOf(hptm), \"null\") == 0 ? 0 : hptm; concat(string(hp + hpt), \"/\", string(hpm + hptm)) }","icon":"fa-heart","expression":true,"isNumber":false,"color":"#9e0000"},{"value":"attributes.ac.value","icon":"fa-shield-alt","expression":false,"isNumber":false,"color":"#0044b3"},{"value":"{  w=<attributes.movement.walk>; concat(string(w), \" m\") }","icon":"fa-shoe-prints","expression":true,"isNumber":false,"color":"#000000"}]},{"disposition":"NEUTRAL","items":[]},{"disposition":"HOSTILE","items":[]}],"static":{"displayNameInTooltip":"FRIENDLY","useAccentEverywhere":false,"accentColor":"#9d2a62","tokenDispositions":["OWNED","FRIENDLY","NEUTRAL","HOSTILE"],"useAccentColorForEverything":false}},"npc":{"items":[{"disposition":"OWNED","items":[]},{"disposition":"FRIENDLY","items":[]},{"disposition":"NEUTRAL","items":[]},{"disposition":"HOSTILE","items":[]}],"static":{"displayNameInTooltip":"FRIENDLY","accentColor":"#870739","useAccentColorForEverything":false,"tokenDispositions":["OWNED","FRIENDLY","NEUTRAL","HOSTILE"]}},"vehicle":{"items":[{"disposition":"OWNED","items":[]},{"disposition":"FRIENDLY","items":[]},{"disposition":"NEUTRAL","items":[]},{"disposition":"HOSTILE","items":[]}],"static":{"displayNameInTooltip":"FRIENDLY","accentColor":"#7a59ea","useAccentColorForEverything":false,"tokenDispositions":["OWNED","FRIENDLY","NEUTRAL","HOSTILE"]}}}}
bmarian commented 3 years ago

That's not a bug. My module replaces what it founds inside <> with the actual value. So in your case:

s = cha; s

Math.js has no idea what to do with the cha and it will consider it a variable. So your formula should look like this:

{ s="<attributes.spellcasting>";s }

image

RayakiTheTurtle commented 3 years ago

Thank you very much for the fast reply! I got it to work now : )