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

Setting a max and min value within ?{Pick atribute| |}



To preface this post I will mention, I am not a programmer so I ask for forgiveness for my transgressions against the gods of logic and mathematics.

I am attempting to create a character sheet for my custom (roll under) d100 ttrpg system using attributes and macros as I am not a pro member. The following code above works as intended, its purpose is to display the DC for a skill check in my system. When making a Skill check the Dm decides the attribute that will be used based on context of the action while the player picks an appropriate skill. Skills are not bound by any attribute in particular so I decided to have every skill check pull up a drop down menu allowing the player to select the attribute as chosen by the DM. For every rank you have in a skill the dc to roll under increases by +5

There is also an exhaustion mechanic where the character builds up "blemishes" either mental {MB} or physical {PB}. For every blemish you have you take -5 against the DC.  So far I managed to get that part to work without much issues. However what I want to be able to do is set the maximum dc to be 95 and the minimum dc to be 5. The current method I attempted was nesting the kh1 command within pick attribute

?{Pick attribute| Phys [[{@{Phys}-[[5@{PB}]],5}kh1]]| Dex [[{@{Dex}-[[5@{PB}]],5}kh1]]| Int [[{@{Int}-[[5@{MB}]],5}kh1]]| Det [[{@{Det}-[[5@{MB}]],5}kh1]]}

This causes the Pick attribute command to freak out and stop working, instead of receiving a drop down menu I get a funky text box with the broken code inside of it as seen below

What it looks like when working:


What it looks like when not working:

Sorry if the way I have written this out is hard to understand but I think I got the idea across. If you guys have any suggestions or clarifying questions then feel free to send em.

March 14 (2 years ago)
timmaugh
Forum Champion
API Scripter

I think you just need commas between your label (for the entry in the query) and the value (returned when you select that label). A query would look like this:

?{Question posed|Label 1,Value 1|Label 2,Value 2}

So your entries should look more like:

?{Pick attribute| Phys,[[{@{Phys}-[[5@{PB}]],5}kh1]]| Dex,[[{@{Dex}-[[5@{PB}]],5}kh1]]|...etc...


If I wanted to set a max value as well and not just a min value how would I go about that? since I cant seem to do bolth

Tried the commas and it still seems to be having the same errors :<

March 14 (2 years ago)
Gauss
Forum Champion

You need to use HTML Entities to replace the "," and the "}" as part of your kh1 calculation (  ....B]],5}kh1.... ) 
The "," and "}" in those parts are going to be seen by the query as commands. 

However, that may still not work, it would require testing. 

Personally, I'd use Chat Menu's instead. They are vastly simpler to execute than queries. 

March 14 (2 years ago)

Edited March 14 (2 years ago)
timmaugh
Forum Champion
API Scripter

My fault... I responded too quickly and didn't see what else you had going on. You're running into a problem of the order of operations for Roll20, and how that impacts roll queries.

Roll queries parse on certain control characters (like pipes to divide options in the list, commas to separate labels from values, and a right brace to denote the end of the query). If it encounters one, it moves into the next phase of parsing. If one of those characters are left in the query when it parses, you'll get unexpected results.

Looking at the order of operations, attributes are expanded before queries are evaluated, so the right brace that closes an attribute (or the pipe separating the character from the attribute, if present), will be gone by the time they would get in the way.

Inline rolls, on the other hand, are handler *after* queries, so the right braces and commas will need to be HTML escaped. Basically, replace the commas in the inline rolls with:

&comma;

...and the right braces in the rolls with:

&rbrace;

Then you should be in business.

DC:?{Pick attribute|[[&lbrace;@{Phys}-[[5@{PB}]] &comma;5&rbrace;kh1]]| Dex [[&lbrace;@{Dex}-[[5@{PB}]] &comma;5&rbrace;kh1]]| Int [[&lbrace;@{Int}-[[5@{MB}]] &comma;&rbrace;kh1]]| Det [[&lbrace;@{Det}-[[5@{MB}]] &comma;5&rbrace;kh1]]}

Like this? or do I need to replace all the braces?
Since when I try to run it nothing happens

Ignore me it works now, thank you