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 a variable with a default value in a roll query

I'm looking for some assistance.  I'm trying to use a default variable in a roll query.   The problem is they both use the | character.  I've tried every work around I can think of.  I've used  &#124, I've used parans, etc. It just does not work.  Either the code thinks the number is the next option in the roll query, or the whole thing craps out, depending on the work around in place.   Here is an example with me just using the | ?{Skill|Axes,{{title=AXES}}{{roll= [[[[ (@{str}+@{axes}) ]]d10d[[ (@{axes}+@{current_wounds}) ]]!+[[ (-3 * @{current_injuries})]] + [[?{Mods|0 & ]]   ]]}}|Next option Or I've done this ?{Skill|Axes,{{title=AXES}}{{roll= [[[[ (@{str}+@{axes}) ]]d10d[[ (@{axes}+@{current_wounds}) ]]!+[[ (-3 * @{current_injuries})]] + [[?{Mods &#124 0 & ]]   ]]}} Any help would be appreciated.   NOTE: I've also seen this issue when trying to embed certain API commands into Roll Queries when they have commands that use | (Like chatattrset).
1561482363
Ziechael
Forum Champion
Sheet Author
API Scripter
Is this nested within another wider macro? It would be useful to see the full thing if so. If not, you shouldn't need to use amp; unless you are more than one query deep. Also, on my phone so being brief, your mods section has a & which appears to be missing it's #125; ending.
Yeah.  That's a typo.   I was just copying it over, but correct in the actual html. It is nested in a larger roll query.  
1561482475

Edited 1561483621
Ziechael
Forum Champion
Sheet Author
API Scripter
Final thoughts, it is advised to only put the necessary bits in queries, since it is identical from the second @{axes} and onwards you can end your query there sparing you from having to nest the current wounds/injuries and mods section completely.
Here's the entire bit. The other options might look a little different btw, but still should have the same general format.  The main problem is that if you don't do the |0 on the ?{Mods} and someone leaves it blank, the entire roll craps out because you then have a +BLANK.   <input name='attr_str_skills' type='hidden' value='&{template:statistics2} {{name=@{character_name}}} ?{Skill|Axes,{{title=AXES}}{{roll= [[[[ (@{str}+@{axes}) ]]d10d[[ (@{axes}+@{current_wounds}) ]]!+[[ (-3 * @{current_injuries})]] + [[?{Mods&124;0&125;]]   ]]}}|Bludgeons,{{title=BLUDGEONS}}{{roll=[[[[ (@{str}+@{bludgeons})]]d10d[[(@{bludgeons}+@{current_wounds})]]!-[[(3 * @{current_injuries})]]+?{ADDITIONAL MODS?}]]}}|Great Weapons,{{title=GREAT WEAPONS}}{{roll=[[[[ (@{str}+@{greatweapons})]]d10d[[(@{greatweapons}+@{current_wounds})]]!-[[(3 * @{current_injuries})]]+?{ADDITIONAL MODS?}]]}}|Hand-to-Hand,{{title=HAND-TO-HAND}}{{roll=[[[[ (@{str}+@{h2h})]]d10d[[(@{h2h}+@{current_wounds})]]!-[[(3 * @{current_injuries})]]+?{ADDITIONAL MODS?}]]}}|Polearms,{{title=POLEARMS}}{{roll=[[[[ (@{str}+@{polearm})]]d10d[[(@{polearm}+@{current_wounds})]]!-[[(3 * @{current_injuries})]]+?{ADDITIONAL MODS?}]]}}}'>
1561486635
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
So, just a headsup, using html entities like that in sheet code can cause issues as they might be parsed, especially if you are planning to submit your sheet to the repo. Also, since you are apparently using this as a custom sheet, I'd recommend using a custom roll template to do conditional display of various elements depending on what is needed. You can either make a flag attribute that will toggle display of roll template sections based on what is entered (like 0 is axes, 1 is bludgeoning, 3 is ...), and/or you can use a select on the sheet for users to select what to roll directly from the sheet.
Second paragraph is a great idea. First paragraph I'm not sure what you mean.  Are you talking about the replacement characters?  &#125?  Those have to be in there or the roll won't work.
1561487701

Edited 1561487750
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
So, when the sheet code is loaded through the roll20 repository, the html encoding can be parsed into their representations, so } becomes } in the code that is actually passed to the game. I don't believe this is something that occurs if you're just using it as a custom sheet, but checking what the actual macro code is in the usable sheet is a good thing to look at. Additionally, I believe Ziechael is correct and you are over encoding the problem characters, you should only need } for being in one roll query; note you may have needed to do this because of my point in the previous paragraph. But, honestly, I would avoid doing nested queries in the sheet code and use the power of a custom sheet to do that selection within the sheet or its roll template. Alternatively, you could use a chat menu instead of a roll query.
By chat menu you're speak of something akin to the Stars Without Number sheet (if you're familiar with it?)
1561490643
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'm not, but something like what is done in the 5e shaped sheet, the Pathfinder Community sheet, the Starfinder by Roll20 Sheet, or what is outlined in this Stupid Trick . I'm sure that there are other sheets that use the technique besides those that I listed, but those are the ones I know use it.
Yeah.  I'm looking at it now.  Thanks for the advice.