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

Using math in a query name?

February 28 (8 years ago)

Edited February 28 (8 years ago)
I have a homebrew resource system that I am trying to create a macro for. This system allows the player to use their mental strength to transfer energy between a source and a target. The amount of energy they can move is a non linear curve based on the amount of mental strength they put into it. You roll a number of d20's such that you can just get the source number, so ceil(sourcenumber/20) this number, capped at the source amount, is how much you apply to your target. I have a query that functionally does what I need it to, but I want the player to know what their max draw from the source is while in the drop down. Which means having my equation for max draw based on mental strength in the query name. Looks like this: "Max draw of [[equation]] ____"

Here is my query(I have this in the abilities section of a character):
/em @{character_name} uses [[?{Alar amount|}]] Alar to draw ([[ ?{Max Draw of [[?{Alar amount|}*?{Alar amount|}-?{Alar amount|}+4]]|} ]]/[[?{Alar amount|}*?{Alar amount|}-?{Alar amount|}+4]] max) Au of energy from the source and apply [[ { [[[[ceil([[?{Alar amount|}*?{Alar amount|}-?{Alar amount|}+4]]/20)]]d20]], ?{Max Draw of [[?{Alar amount|}*?{Alar amount|}-?{Alar amount|}+4]]|}}kl1 ]] Au of energy to the target.
February 28 (8 years ago)

Edited February 28 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
resolution of math equations requires rolls (either /r or inline rolls). These are not resolved until after roll queries, so there is unfortunately no way to do what you want to do in a single click macro. There is some API command button fanciness that can do what you want with two clicks. The macro involves a lot of html encoding, so I've posted it as a gist.

EDITs:
Note: API command buttons are available to all subscription levels, and do not require access to the API to be used.

Note 2: Because this macro uses html encoding, make sure you save it in your game as a character ability, not as a global macro. The global macro editor will eat one level of html encoding each time you open and resave the macro.

I've also got a suggestion for your equation. You could change your max draw equation to be [[?{Alar amount|}*(?{Alar amount|}-1)+4]]
Awesome! This should be able to handle what I want. Thank you for the help!
February 28 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
happy rolling