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

status_XXX token markers read/write inconsistency #69

Closed phylll closed 3 years ago

phylll commented 3 years ago

This is probably just a documentation gap, but maybe the actual behavior could be slightly more elegant, as well:

As documented, setattr(sender, "status_yellow", show) accepts values for show of either true or false and does what you would expect it to do.

However, while getattr(sender, "status_yellow") does return false if "off", it returns shown, not true, if "on".

michael-buschbeck commented 3 years ago

It's intentional, if obscure: true in numeric context would be interpreted as 1, whereas "shown" would be interpreted astrue as well as 0.

It's a bit like "0 but true" returned by Perl's ioctl() call.

michael-buschbeck commented 3 years ago

…with the intention being that status marker attributes – which can also be assigned a number 1...9 to show as a badge – return something truthy-but-zero when they're shown without a number on them. Otherwise it would be very hard to distinguish "shown with number 1 on it" from "shown without a number on it".

@phylll, does this make sense from a user's point of view? Do you think documentation would fix it, or should it be done differently?

(Fully embracing Perl's legacy here and making it "0 but true" might be confusing because the badge wouldn't actually show the number 0.)

phylll commented 3 years ago

Makes sense, and I don't see a good way of making it more elegant given Roll20 stores the display status and the payload (the number) in the same value. So yes, documenting this should be sufficient.

michael-buschbeck commented 3 years ago

Will do!

When I was implementing this, I pondered the option of presenting two separate quasi-attributes – say, status_foo_shown and status_foo_digit –, but I thought users would be surprised if setting shown to false would also implicitly clear digit (because, as you say, Roll20 doesn't provide independent storage for the digit).

I guess some level of surprise can't be avoided here (short of implementing MMM-internal shadow storage for digit of currently hidden status markers).