Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

subtract for question in & {template: default}

Is there a way that inside a "& {template: default} {{name = ???}}" there can be a question "[[1d100 +? {Karma = Damage Bonus | 0} + 2 @ {Strength} ]] "and that this value set by the player in the question is subtract from one of the spheres of the token. I tried it with TokenMod and with,! Modattr whit, $[0], and I could only achieve it is by creating another question in addition to the first question but outside the & {template: default} {{name = ???}}. but I want to do it in one question.
1638543287

Edited 1638543999
timmaugh
Forum Champion
API Scripter
So... if you start a message as a template output, you aren't triggering the API. Conversely, if you start an API message, your text doesn't hit the chat, and what you have to make do with is whatever the receiving script will output. But there is a workaround with the Meta Toolbox. ZeroFrame allows you to output text (to the chat) that began as an API command, including templates, and Plugger lets you embed secondary, outbound calls to run a script WITHIN your original command line. All of that together would let you do something like: !&{template:default}{{name=Something Happened}}{{Damage Taken=[[1d100+?{Damage Bonus|0} + (2 * @{selected|Strength})]]}}{&simple}{&eval}!token-mod --set bar3|-$[[0]].value{&/eval} Explanation Everything between the EVAL tags is the Token-Mod command, so substitute your own in, there. I used the syntax for decrementing the value of the roll from bar3, but you know better what you want to accomplish. Since the roll is happening in THIS message (not the message sent to TokenMod), we have to extract the roll value while we're here. We do that with the .value construction pegged onto the backside of the roll marker. As far as TokenMod knows (when it gets the message), this was just a simple value we passed, not an inline roll, but the effect is the same. We start it with an exclamation point to trigger the API, but we include the {&simple} tag so that whatever remains in the command line after all of the metascript processing has completed is sent to the chat. In this case, that will include our templated layout... but by the time the metascript processing is done, the EVAL tags have sent the command to TokenMod, and they and everything they enclose is removed from the command line. EDIT: Scripts Needed To pull this off, you'd need ZeroFrame, Plugger, and Token-Mod. Also, I used the selected token where you'd used a sheet shorthand reference. If you want to use selected tokens in an API call (this one or others) and you have ZeroFrame installed, you will need SelectManager.
thx Timmaugh for all, what you put is exactly what I needed Thanks I don't know if I had to install the 4 APIs but it worked perfect for me.
1638654406

Edited 1638654720
Timmaugh, when I was launching the old macro, you would see the dice when a roll was made, but now with the !&{Template: default} the dice are not displayed when the macro is launched because of the (!) There is no way to that the roll of the dice can be seen on the board?
1638657429
timmaugh
Forum Champion
API Scripter
Glad it is working... there is currently no way to trigger the die rolling with an API call like this (which it is, even if it ultimately outputs a template). Aaron had worked out a way in another script, but it was a very involved process he said I was welcome to steal, though he warned me off of it. >D So far I haven't tried to weave it into the metascripts.
1638657461
timmaugh
Forum Champion
API Scripter
But doing it this way you can at least hover over the inline rolls to see what the individual parts were in the roll.
1638672110

Edited 1638707658
David M.
Pro
API Scripter
I wonder if the new "computed" property for inline rolls would work. Check out this post . I'd test it out, but I'm beat and headed to bed early. EDIT - nope. Still limited to re-using the rolls on the same line, so Tim's trick seems the best solution.