Aedif / TokenVariants

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

[Bug] Effect Config Input of Composite Expressions with Multiple Strings #117

Closed harrisog closed 1 year ago

harrisog commented 1 year ago

When typing composite expressions with more than one component wrapped in string quotes into the Effect Config, inputting the second character of the second string causes the text selector to unexpectedly move to the beginning of the input field.

Example: lockRotation="true" && name="Raging Barbarian"

Copy-pasting in from elsewhere seems to bypass, but any attempt to further edit the expression inside the Effect Config will result in the bug.

Aedif commented 1 year ago

Should be fixed in https://github.com/Aedif/TokenVariants/releases/tag/4.44.0

harrisog commented 1 year ago

I'm encountering a related bug with composite expressions and quotes with the TMFX preset. Example: Dazzled && \{ name="Orc Brute" || name="Orc Warrior" || name="Orc Warchief"\}

The preset works as expected for the first match in the array, but does not automatically delete itself for any matches in later array positions.

And piggybacking off this example with a QoL feature request: please consider extending wildcard searches to name strings? E.g., Dazzled && name="Orc*"

Aedif commented 1 year ago

For that kind of expression you need to use parentheses () not curly brackets {}

Aedif commented 1 year ago

Curcly brackets are purely used for matching a string to some effect name akin to how you would use them in Token Image Wildcards (https://foundryvtt.com/article/tokens/). I intentionally made syntax the same.

For logical expression you want to use the parentheses. Think of each part of the expression as being ture or false and translate it as so:

Dazzled && \( name="Orc Brute" || name="Orc Warrior" || name="Orc Warchief" \)

true && (false || false || true)

If what you end up with can be pasted into your browser console and evaluates without error, you have a valid expression.

Aedif commented 1 year ago

If instead of Dazzled you used Dazzled \{1,2,3\} The module would evaluate the whole of Dazzled \{1,2,3\} as either true or false depending on whether the token has a dazzled effect with the name Dazzled 1, Dazzled 2, or Dazzled 3, and this would be plugged back into the logical expression:

Dazzled \{1,2,3\} && \( name="Orc Brute" || name="Orc Warrior" || name="Orc Warchief" \)

true && (false || false || true)

harrisog commented 1 year ago

Gotcha, tried again with parnetheses and everything's working as expected. Thanks again!