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

Support translation variants #62

Open michael-buschbeck opened 3 years ago

michael-buschbeck commented 3 years ago

The translate command (see #47) replaces a single chat output with a single translated message. Sometimes I'd be a lot nicer (or even a linguistic necessity) to be able to provide variants based on runtime criteria.

Consider this:

Line Command
1 !mmm translate [UsedAmmo]: Shot an arrow, and still $[NumAmmo] more to come!
2 !mmm chat [UsedAmmo]: Used one, have $[NumAmmo]{EndAmmoCount} left

Even with translation, this can result in variously clunky messages:

It would be nice to be able to provide translation variants depending on the $[NumAmmo] value:

michael-buschbeck commented 3 years ago

Tentative syntax:

Line Command
1 !mmm translate [UsedAmmo] using variants
2 !mmm     variant if $[NumAmmo] == 0: Shot an arrow. All empty now – this one has to count.
3 !mmm     variant if $[NumAmmo] == 1: Shot an arrow, and there's still one more to come!
4 !mmm     variant otherwise: Shot an arrow, and still $[NumAmmo] more to come!
5 !mmm end translate
michael-buschbeck commented 3 years ago

I really have to support a "safe" side-effect-free version of expression evaluation then – wouldn't want players to sneak in the odd setattr() or chat() function in their translation variant preconditions.

(To be fair, they don't have to "sneak" anything in anywhere as long as they could just do !mmm do on their own.)

michael-buschbeck commented 3 years ago

More important than being side-effect-free is that variant preconditions are evaluated against the customize block's variable stash, not the executed script's.

michael-buschbeck commented 3 years ago

Blocked by #117 because having an expression in front of a template requires a cleverer command parser.