michael-buschbeck / mychs-macro-magic

A simple, sane, and friendly little scripting language for your Roll20 macros.
MIT License
1 stars 1 forks source link

Improve `findattr()`'s value matching #112

Open michael-buschbeck opened 3 years ago

michael-buschbeck commented 3 years ago

Right now, findattr(id, col, val) coerces both val and the value found in the col attribute to strings and compares those for case-insensitive equality.

We've come across situations where character sheets are inconsistent in how they represent equivalent values – e.g. 1 vs true.

Make findattr()'s value matching more semantic by coercing the attribute's value to the reference value's type (e.g. bool if true is given, number if 1 is given, else case-insensitive string) instead of coercing both to string.

michael-buschbeck commented 3 years ago

Notice that "false" doesn't coerce to bool false, but should obviously match.

Interpretation "as a number" or "as a bool" may have to be separate from coercion.