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

"Keep Lower number" Within queries.

Good evening!  I've lately been having an issue with making a function within a query to choose between two options. Such as: ?{What shot count is this? |First, 0, [[ -1 + 5]], kl1 |Eighth, [[0, [[-8 + 5]]]]kl1} The goal is to return a negative number or a 0 if the math within [[-x + 5]] goes positive. I've attempted two separate methods for returning the correct result. So far both query "First" and "Eighth" return 0. I presume the issue lies with the use of a comma or incorrect use of curly brackets, parentheses, or straight brackets.
1667184150

Edited 1667184246
Gauss
Forum Champion
This fixes the issue you were having, but it is not the best way to do it. ?{What shot count is this?|First,[[{0,[[-1 + 5]]}kl1]]|Eighth,[[{0,[[-8 + 5]]}kl1]]} Issue 1: To do a keep low you need {  0,[[-x+5]]  }  kl1  Note the "{" and "}" brackets.  However, that will break the query.  Issue 2: A Query looks for { and }. Your first kl } will end the query.  Example: ?{This query won't work|Low,{0,5}kl1|High,{0,5}kh1} is seen as: ?{This query won't work|Low,{0,5} Because that first "}" is the "end" of the query.  Solution: HTML entity "}" = "}" Issue 3: A query is looking for commas "," to differentiate between name and output.  Example: ?{This query won't work|Low,{0,5}kl1|High,{0,5}kh1} is output as: {0 because the output ends at the "," Solution: HTML entity "," =  , Full solution: ?{This query will work|Low,{0,5}kl1|High,{0, 5} kh1} Note the HTML entity substitutions for "}" and ",".  Next, I get the impression that "-x" is going to be a variable of some other kind. What do you plan on putting in the "-x" slot? If it is an attribute or a macro that will break the query all over again if not done right. Finally, this is a much simpler version of this macro: [[{0,[[-?{What shot count is this?|First,1|Eighth,8}+5]]}kl1]] It moves the query into the math rather than reproducing the math multiple times.  It doesn't require HTML entities, and it probably won't break as easily.
1667188479

Edited 1667189856
Gauss said: This fixes the issue you were having, but it is not the best way to do it. ?{What shot count is this?|First,[[{0,[[-1 + 5]]}kl1]]|Eighth,[[{0,[[-8 + 5]]}kl1]]} Issue 1: To do a keep low you need {  0,[[-x+5]]  }  kl1  Note the "{" and "}" brackets.  However, that will break the query.  Issue 2: A Query looks for { and }. Your first kl } will end the query.  Example: ?{This query won't work|Low,{0,5}kl1|High,{0,5}kh1} is seen as: ?{This query won't work|Low,{0,5} Because that first "}" is the "end" of the query.  Solution: HTML entity "}" = "}" Issue 3: A query is looking for commas "," to differentiate between name and output.  Example: ?{This query won't work|Low,{0,5}kl1|High,{0,5}kh1} is output as: {0 because the output ends at the "," Solution: HTML entity "," =  , Full solution: ?{This query will work|Low,{0,5}kl1|High,{0, 5} kh1} Note the HTML entity substitutions for "}" and ",".  Next, I get the impression that "-x" is going to be a variable of some other kind. What do you plan on putting in the "-x" slot? If it is an attribute or a macro that will break the query all over again if not done right. Finally, this is a much simpler version of this macro: [[{0,[[-?{What shot count is this?|First,1|Eighth,8}+5]]}kl1]] It moves the query into the math rather than reproducing the math multiple times.  It doesn't require HTML entities, and it probably won't break as easily. So essentially replace any characters that would break the query with its HTML counterpart. Am I able to google HTML entity values or do you possibly have a resource I can check out? You assume correctly that "-x" is a variable. Of which is how many "shots" a character has made and is equivalent to the string name of the query option, as shown in the example ?{ First , - 1 | Second , - 2 and so on. However, the "5" in the expression is a replacement value for a character's Strength modifier. I replaced the str mod with 5 for ease of explanation. I've successfully been able to place @{Character Name|Strength_mod} where the 5 is with no issues. But I do appreciate you asking.  Wow that simplified version is quite fascinating, thank you very much for your detailed reply. Much appreciated.  EDIT: I've noticed when I tried utilizing your simpler version of the macro, with @{CharName|Strength_mod}, there is an additional "0" that shows up in the damage bar on a new line. As shown in the second to last attack roll in chat:   The last attack roll made was made without the attack bonus macro unchecked. Do you possibly know why that shows up?
1667215784

Edited 1667215914
Gauss
Forum Champion
HTML Entities: <a href="https://wiki.roll20.net/HTML_Entities" rel="nofollow">https://wiki.roll20.net/HTML_Entities</a> It is not a full list though, for a full list you can google HTML Entities.&nbsp; For the "0" you would have to show me the entire setup.&nbsp; Please hit the macro/attack that has the "0" in it, then go to the chat and hit the up arrow, copy what it gives you and post that here.&nbsp; Also I need a screenshot of your character sheet.
Gauss said: HTML Entities: <a href="https://wiki.roll20.net/HTML_Entities" rel="nofollow">https://wiki.roll20.net/HTML_Entities</a> It is not a full list though, for a full list you can google HTML Entities.&nbsp; For the "0" you would have to show me the entire setup.&nbsp; Please hit the macro/attack that has the "0" in it, then go to the chat and hit the up arrow, copy what it gives you and post that here.&nbsp; Also I need a screenshot of your character sheet. Thank you for that link. Here is the copy/paste of the attack with the "0" in it: @{Garrick Daus|wtype}&amp;{template:atkdmg} {{mod=+5}} {{rname=Gun}} {{r1=[[@{Garrick Daus|d20}cs&gt;20 + 3[DEX] + 2[PROF]]]}} @{Garrick Daus|rtype}cs&gt;20 + 3[DEX] + 2[PROF]]]}} {{attack=1}} {{range=big feet}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d6 + 3[DEX]]]}} {{dmg1type=Piercing}} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d6[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=*12 shots per magazine* / ***Three shots per turn***}}&nbsp; &nbsp;{{spelllevel=}} {{innate=}} {{globalattack=@{Garrick Daus|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{Garrick Daus|global_damage_mod_type}}} ammo=Bullets @{Garrick Daus|charname_output} Here is the character sheet: Let me know if you need to see any more pages of the character sheet. As a note, I do not currently have Pro so I do know that ammo tracking will not work.
1667241618

Edited 1667242295
Whoops!
1667241961

Edited 1667242151
Gauss
Forum Champion
Odd, so apparently if you have no number in that field it causes a minor bug. The resolution is put 0+ before the line I gave you. Example: "0+ [[{0,[[-?{What shot count is this?|First,1|Eighth,8}+5]]}kl1]]" (without quotes)
1667242017

Edited 1667242105
Gauss
Forum Champion
Jarren said: You've got a bit of extraneous code in there: @{Garrick Daus|wtype}&amp;{template:atkdmg} {{mod=+5}} {{rname=Gun}} {{r1=[[@{Garrick Daus|d20}cs&gt;20 + 3[DEX] + 2[PROF]]]}} @{Garrick Daus|rtype}cs&gt;20 + 3[DEX] + 2[PROF]]]}} {{attack=1}} {{range=big feet}} {{damage=1}} {{dmg1flag=1}} {{dmg1=[[1d6 + 3[DEX]]]}} 0 {{dmg2=[[0]]}} {{dmg2type=}} {{crit1=[[1d6[CRIT]]]}} {{crit2=[[0[CRIT]]]}} 0 {{desc=*12 shots per magazine* / ***Three shots per turn***}} {{spelllevel=}} {{innate=}} {{globalattack=@{Garrick Daus|global_attack_mod}}} {{globaldamage=[[0]]}} {{globaldamagecrit=[[0]]}} {{globaldamagetype=@{Garrick Daus|global_damage_mod_type}}} ammo=Bullets @{Garrick Daus|charname_output} {{dmg1type=Piercing}} You shouldn't need any of the code that is bolded with strikethrough. One of those is causing the extra '0' to display. And I don't think you'll need&nbsp;{{globalattack=@{Garrick Daus|global_attack_mod}}} or&nbsp;{{globaldamagetype=@{Garrick Daus|global_damage_mod_type}}} either, if your globaldamage and globaldamagecrit values are 0. You might have misunderstood what was being done, that wasn't a Macro that was posted. That was the command from the attack itself. I needed to see what it was doing and so asked KingFourth to supply the command from the attack.&nbsp; The attack contained the extra bits, that is directly from the character sheet attack and cannot be changed.&nbsp;
Gauss said: You might have misunderstood what was being done, that wasn't a Macro that was posted. That was the command from the attack itself. I needed to see what it was doing and so asked KingFourth to supply the command from the attack.&nbsp; The attack contained the extra bits, that is directly from the character sheet attack and cannot be changed.&nbsp; Haha yep! I skimmed the original part a bit too quickly and thought this was referring to a custom chat macro: I've noticed when I tried utilizing your simpler version of the macro, with @{CharName|Strength_mod}, there is an additional "0" that shows up in the damage bar on a new line. As shown in the second to last attack roll in chat:
Jarren said: Whoops! I do appreciate the attempt at helping!
Gauss said: Odd, so apparently if you have no number in that field it causes a minor bug. The resolution is put 0+ before the line I gave you. Example: "0+ [[{0,[[-?{What shot count is this?|First,1|Eighth,8}+5]]}kl1]]" (without quotes) I'm curious what is causing the bug? Is it the way that specific function interacts with the global attack modifier? Either way, that did fix the issue, and I'm very grateful for all of your help.&nbsp;
1667246398
Gauss
Forum Champion
Character sheets can have quirks, if not outright bugs. For example, there is one location in the sheet that will do some hidden math that isn't expected (multiply by 10). No idea why but it happens.&nbsp; Apparently this section of the sheet has a quirk where it wants a value, and if it doesn't have a value it puts a 0 in a field that normally doesn't exist. No idea why, just is.&nbsp; If the character sheet was not a "by Roll20" sheet then maybe a character sheet guru could look at it, but the "by Roll20" sheets are proprietary so, nope.
1667247270
Kraynic
Pro
Sheet Author
Gauss said: Apparently this section of the sheet has a quirk where it wants a value, and if it doesn't have a value it puts a 0 in a field that normally doesn't exist. No idea why, just is. If a macro calls on an attribute that has no value, that tends to break the macro if there are a string of attributes being called.&nbsp; Ever had a macro fail due to having a double + sign?&nbsp; Instead of "diceroll+@{modifier1}+@{modifier2}", the dice roller is seeing something like "diceroll++@{modifier2}" (assuming modifier 2 has a value and 1 doesn't).&nbsp; That is why most sheets will set a default value of 0 in the html for any attribute that is called by a macro (at least macros that are built into roll buttons).&nbsp; There are some ways to work around this, like inserting a zero right before the attribute call in the macro, but setting a default is probably the most common way to make sure roll buttons/macros work even if the values haven't been fully filled in yet.
1667248701
Gauss
Forum Champion
Kraynic said: Gauss said: Apparently this section of the sheet has a quirk where it wants a value, and if it doesn't have a value it puts a 0 in a field that normally doesn't exist. No idea why, just is. If a macro calls on an attribute that has no value, that tends to break the macro if there are a string of attributes being called.&nbsp; Ever had a macro fail due to having a double + sign?&nbsp; Instead of "diceroll+@{modifier1}+@{modifier2}", the dice roller is seeing something like "diceroll++@{modifier2}" (assuming modifier 2 has a value and 1 doesn't).&nbsp; That is why most sheets will set a default value of 0 in the html for any attribute that is called by a macro (at least macros that are built into roll buttons).&nbsp; There are some ways to work around this, like inserting a zero right before the attribute call in the macro, but setting a default is probably the most common way to make sure roll buttons/macros work even if the values haven't been fully filled in yet. I don't think that explains why there is an extraneous field with a 0 in it.&nbsp; Examples:&nbsp; In the global attack modifier a 1d4 works fine But if you put&nbsp; [[{0,[[-?{What shot count is this?|First,1|Eighth,8}+5]]}kl1]] it works fine, but then creates an extraneous field with a "0" in it?&nbsp; I don't think your explanation above explains that one, but I am not a sheet coder and you are, so maybe it does and I am missing it. :) In any case, adding a 0+ to the front works to get rid of the extraneous field.
1667250436
Kraynic
Pro
Sheet Author
Gauss said: I don't think that explains why there is an extraneous field with a 0 in it.&nbsp; Examples:&nbsp; In the global attack modifier a 1d4 works fine But if you put&nbsp; [[{0,[[-?{What shot count is this?|First,1|Eighth,8}+5]]}kl1]] it works fine, but then creates an extraneous field with a "0" in it?&nbsp; I don't think your explanation above explains that one, but I am not a sheet coder and you are, so maybe it does and I am missing it. :) In any case, adding a 0+ to the front works to get rid of the extraneous field. I was explaining why sheets fill in a 0 value for things, not specifically why the roll template in the screenshot had a new section/line with a zero.&nbsp; The zero in the screenshot isn't just an extra 0, but is being displayed in a new section of the roll template, meaning that there is something in the way the macro is written that is triggering the roll template to create a new section.&nbsp; I don't play/run D&amp;D 5E, so I'm not real familiar with how the 5E sheet and template work.&nbsp; I do know that some (most?) of the rolls triggered from a button are not really complete as far as the specific macro code for the roll button in the html is concerned, but are being assembled by sheet workers depending how various sheet option settings are configured.&nbsp; With that being the case, there may be some unintended consequences for where the roll button thinks a new line/section should start/end based on where it ends up perceiving curly bracket double pairs when you start adding bits of macro internally to what the button is trying to do.&nbsp; It may be something that goes away with further html substitutions, but I will leave that up to you to test (or not!).
1667252277

Edited 1667252303
Gauss
Forum Champion
Naw, the solution was simple enough to add a 0+ to the front of the inline. I just chalk this up to a weirdness of "by Roll20" :)