
So, here's my slightly-complex situation. I'm building a character sheet that includes a repeating list of custom techniques that characters can use. I want each tech to have a 'Use Technique' button that auto-rolls the tech, but a technique can have an arbitrary number of targets based on what it does, how many enemies are in range, et cetera. Use Technique is pretty complex - displaying damage, automatically reducing Stamina, checking if it's still on cooldown, et cetera - so it's not just a feed-numbers-in macro. I've made a !tech command in the API that does all the dirty work, and that can take in a list of targets as a parameter (!tech --targets id1 id2 id3).The part I'm having trouble with is getting that list. To my knowledge, there's no way to write a command that prompts the user for an arbitrary number of targets - you just put in the right number of @{target|Name|token_id} blocks, and then roll20 prompts the roller for each one accordingly. I've worked around this by adding a "Targets" field next to the Use Technique button where the user can enter the number of targets they want to hit, and a worker on the character sheet accordingly alters the Use Technique button's backing roll; for example, if Alice sets Targets to 2 on Fireball, then the button's backing roll changes to '!t --as "@{Alice|character_id}" "Fireball" +0 --targets @{target|Target #1|token_id} @{target|Target #2|token_id}". However, even this overengineered method lands me with a really messy UX, because of how worker change events work. The value of Targets doesn't trigger as "changed" until the field loses focus - if you click the up arrow to raise it to 2, it's still 1 until you click outside the field. So, if the user sets Targets to 2 and then immediately clicks Use Technique, the sheet hasn't had time to update the button, so it still fires off with just one target. Is there some easier way to do this that I'm overlooking? I feel like this has gotten way more complex than it ought to be.