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

Problem with Treshold adding "greater then"

1719832045

Edited 1719832098
Hi, I want to create a roll that sums the difference between an attribute and a given number. I'm working to a new sheet, and in the choosen game system you have certain abilities that once reached a certain number of points add bonus to other abilities. What I'm trying to do here is: IF ability points are 7 THEN you add 1, BUT IF ability points are 6 THEN you add 0 I took example from the Thierry MATTRAY Pendragon 5th edition sheet on Roll20, that use this line to calculate the difference: [[{{@{SIZ}+?{modif|0},0}>21}*(@{SIZ}+?{modif|0}-20) + 0]] But when i took out the ?{modif|0},0} part, the roll doesn't work anymore. These are my attempt to the new line: [{@{Ricaricaveloce_Skill}>7}*(@{Ricaricaveloce_Skill}-6) + 0]] [{{@{Ricaricaveloce_Skill}+0}>7}*(@{Ricaricaveloce_Skill} + 0]] What am I doing wrong?
1719834456

Edited 1719837684
First, just to make sure you're aware (as this trips up many people initially), in Roll20 dice syntax, " > " means "greater than or equal to" and " < " means "less than or equal to".   It looks like you have a malformed attribute. Is Ricaricaveloce the name of the character? Then you need a vertical pipe separator if 'Skill' is the name of the attribute: @{Ricaricaveloce|Skill} What is the name of the character, and what is the name of the attribute you are trying to reference? An attribute has several parts. Using "@{CHARACTERANME|ATTRIBUTENAME|MAX} as an example: @{  < - this tells Roll20 to look for an attribute CHARACTERNAME  is the reference for which character sheet to pull the information from.  It can be replaced by "selected" to use the linked sheet from a selected token, or "target" to use the linked sheet from a targeted token. If you use 'target', then you can use an additional optional section with another vertical pipe to identify the target such as @{target|target1|Skill} or @{target|target1|Skill|max}. If the attribute call is on the character sheet itself, then this is optional. |  <- this separates the character reference from the attribute name ATTRIBUTENAME  is the exact name of the attribuete you want to pull from the character sheet |MAX  <- this is optional, and will pull data from the 'max' field of the chosen attribute }  <- this closes the attribute call The first step in troubleshooting macros that include attribute calls is to make sure the attribute calls work on their own. You should be able to put @{Ricaricaveloce|Skill} into chat and get an output, and not an error message.  If you get an error message, then that is what is breaking your macro. See if this works: (I've added a 0 in front in case the attribute call fails per this trick) [[{0@{Ricaricaveloce|Skill}>7}*(0@{Ricaricaveloce|Skill}-6) + 0]]
Thank you for your answer Jarren. I'm aware that you need to refer to the Character when you roll on chat, but when you are writing a roll INSIDE the sheet HTML you don't need to do it. Ricaricaveloce_skill (italian for Fast Reload) is the name of the attribute. Anyway, if tried your formula (changing the attribute) but I still get error. I've also tried in chat adding "selected", but nothing. The attribute itself exist (if i just type @{selected|Ricaricaveloce_Skill} on chat it shows, but the line is not working.
1719837729

Edited 1719839536
timmaugh
Pro
API Scripter
You only have a single opening bracket. Inline rolls should have a double opening & closing: [[ ... ]] Also, if you are going to compare against a value, you need a string of options. You can see that the first line you were trying to copy has a 0 in the set of numbers compared against 21 (it immediately follows the modifier you removed, along with a brace, so you might have thought that it was part of the query and inadvertently removed it. Anyway, all of that together should give you something like: [[{@{Ricaricaveloce_Skill},0}>7}*(0@{Ricaricaveloce_Skill}-6) + 0]]
LU MASTER said: I'm aware that you need to refer to the Character when you roll on chat, but when you are writing a roll INSIDE the sheet HTML you don't need to do it. Ricaricaveloce_skill (italian for Fast Reload) is the name of the attribute. Anyway, if tried your formula (changing the attribute) but I still get error. I've also tried in chat adding "selected", but nothing. The attribute itself exist (if i just type @{selected|Ricaricaveloce_Skill} on chat it shows, but the line is not working. Ok try this: (Selected token) [[{0@{selected|Ricaricaveloce_Skill},0}>7*(0@{selected|Ricaricaveloce_Skill}-6) + 0]] (Character ability) [[{0@{Ricaricaveloce_Skill},0}>7*(0@{Ricaricaveloce_Skill}-6) + 0]] You were missing an opening [, and also the Success roll was malformed (a Success roll requires at least two numbers to be "compared", so I added a '0' to compare against)
It works! Thank you!
Ok, I have another problem now: the formula works, but if I want to show the results directly on an attribute inside the sheet (not in a macro, a scriptcard or in a "roll"), it just display the formula itself and not the result. Any suggestion?
LU MASTER said: Ok, I have another problem now: the formula works, but if I want to show the results directly on an attribute inside the sheet (not in a macro, a scriptcard or in a "roll"), it just display the formula itself and not the result. Any suggestion? I don't fully understand where you want to show the formula and what you want it to look like. Could you include a screenshot? Or a mockup of what you want it to look like? If you don't want to show the output of the roll, you should need to just remove the square brackets: {0@{Ricaricaveloce_Skill},0}>7*(0@{Ricaricaveloce_Skill}-6) + 0
1719937857
GiGs
Pro
Sheet Author
API Scripter
LU MASTER said: Thank you for your answer Jarren. I'm aware that you need to refer to the Character when you roll on chat, but when you are writing a roll INSIDE the sheet HTML you don't need to do it. Ricaricaveloce_skill (italian for Fast Reload) is the name of the attribute. Just a quick (and pointless and pedantic) clarification: the roll ALWAYS needs the character name, but Roll20 supplies the character name for you in this case, and you never see it. For your situation, it sounds like you need either an autocalc field or a sheet worker (these will auto-calculated an attribute for you). As Jarren asked, can you describe more about how this attribute appears on the sheet.
1719962628

Edited 1719962958
I want to use the formula on two sheets. Also, consider that i'm no expert of HTML and CSS, as I've just started experimenting with it: 1) Since I'm displeased with the official Pendragon 6 sheet, i'm working on a modified version of the Thierry MATTRAY Pendragon 5th ed. Sheet. In Pendragon 6 the passions are sorted in "Courts" with a total cap of 40 for each court, BUT - by rules - if your passion's value is bigger then 20, the court's cap count it ONLY as 20 anyway. Here's an example with the court FIDELITAS. That's where I want to display it (near the name): And That's my formula (I've only try an attemp with the Homage passion, named 'HOMA'. I named the formula for the treshold as 'HOMAcourt'. <label style='display:inline-block; width:180px;'>FIDELITAS</label> <input style='display:inline; width:30px; font-color:red;' type="text" name="attr_currentpas" value="(@{HOMA}+@{HOMAcourt}+@{LOY}+@{LOY2}+@{FEAL}+@{DUTY})" disabled="true"/> <label style='display:inline'>/</label> <input style='display:inline;' type="text" name="attr_attr_fidelitas" class="sheet-carac2" value="40" disabled="true" /> <br /> <label style='display:inline-block; color:black; margin-left: 5px; font-size:15px; color:black; width:60px;'>Homage</label> <input style='display:inline; margin-left: 10px; width:116px;' type="text" name="attr_HOMAWHO" class="sheet-long" /> <input style='display:inline;' type="number" name="attr_HOMA" class="sheet-carac2" value="0" /> <input style='display:inline;' type="number" name="attr_HOMAcourt" class="sheet-carac2" value="({0@{HOMA},0}>21*(0@{HOMA}-20) + 0)" /> <input style='display:inline; margin-left: 10px; margin-right: 10px;' type='checkbox' name='attr_CB-HOMA' value='1' /> <button type='roll' name='roll_TestHOMA' value="/em @{MYNAME} rolls HOMAGE @{HOMAWHO} with a modifier of ?{modif|0} : \n/roll 1d20+[[{{@{HOMA}+?{modif|0},0}>21}*(@{HOMA}+?{modif|0}-20) + 0]]<[[@{HOMA}+?{modif|0}]] \ HOMAGE @{HOMA} roll @{HOMA} modif. ?{modif|0}"></button> <br / 2) I'm working also on a modified version of Tony R. Cyberpunk 2020 Character Sheet for my own verision of the Interlock System. In this system, if you have 7 points in some of the Special Abilities, they will give you a bonus to certain other abilities/action/other stuff. For example, IF you have 7 points on the ability 'RICARICA VELOCE', (quick reload) you will get a +1 bonus to 'ARMI DA FUOCO' (firearms). That's where I want to display it (il'also circle the Special Ability in question that gives the bonus): That's the code with the formula: <tr> <td><input type='checkbox' class="sheet-classed" name='attr_RicaricaveloceChip' value='1'><span></span></td> <td><button type='roll' style="background-color: #272526; width:160px;" class="sheet-skillroll sheet-set" value='&{template:skill-general}{{skill= Ricarica Veloce}}{{character= @{character_name}, @{handle} }}{{total= [[1d10!!+@{Ricaricaveloce_Skill}+@{Ricaricaveloce_mod}+[[@{Ref}]]+?{Modifier|0}]] }} {{fumble= [***FUMBLE!***](!#fumblearma) }} '><label style=" color: white; text-align:center;" >Ricarica Veloce</label></button></td> <td><input type="text" style="width: 45px;" name="attr_Ricaricaveloce_Skill" Value="0" /></td> <td><input type="text" style="width: 45px;" name="attr_Ricaricaveloce_mod" Value='0'/></td> <input type="hidden" name="attr_RicaricaveloceBonus" disabled="disabled" value="[[{0@{Ricaricaveloce_Skill},0}>7*(0@{Ricaricaveloce_Skill}-6) + 0]]" /> </tr> ...A LOT OF LINES LATER... <table style="width:350px;"> <tr> <td><input type='checkbox' class="sheet-chipped" name='attr_ArmidafuocoChip' value='1'><span></span></td> <td><button type='roll' style="background-color: #272526; width:160px;"" class="sheet-skillroll sheet-set" value='&{template:skill-general}{{skill= Armi da fuoco}}{{character= @{character_name}, @{handle} }}{{total= [[1d10!!+@{Armidafuoco_Skill}+@{Armidafuoco_mod}+[[@{Ref}]]+?{Modifier|0}]] }} {{fumble= [***FUMBLE!***](!#fumblearma) }} '><label style="color: white; text-align:center;">Armi da fuoco</label></button></td> <td><input type="text" style="width: 45px;" name="attr_Armidafuoco_Skill" Value="0" /></td> <td><input type="text" style="width: 45px;" name="attr_Armidafuoco_mod" Value=' @{RicaricaveloceBonus} 'disabled="true"/></td> </tr> </table>
Ah. This needs to be posted in the  Character Sheets & Compendium forum . You'll get much better advice there.
1719970862
GiGs
Pro
Sheet Author
API Scripter
Seconding Jarren's comment, but it'll be a good idea to post an update here that you have created that new question. For pendragon, you'll need to list which courts exist, and which passions are in each of them. The Interlink version looks straightforward with a bit of planning. You'll need an attribute which holds the calculated bonus or any specific group like firearms, and then include that attribute wherever you neeed the firearms bonus.
1720003138

Edited 1720004706
Jarren said: Ah. This needs to be posted in the  Character Sheets & Compendium forum . You'll get much better advice there. GiGs said: Seconding Jarren's comment, but it'll be a good idea to post an update here that you have created that new question. Yeah, I'm gonna post there. I'm gonna continue on this topic: Problem: Making an attribute with a treshold adding "greater then" as value . Anyway, I'm gonna post here any update. Thank you both!
1720133696

Edited 1720133960
So, I'll post here the resolutive Text Workers formulas. Both were written by GiGs. For a further explanation, check the topic that I have linked on the previous message: 1) Modified version of Tony R. Cyberpunk 2020 Character Sheet; creating an attribute which value is a bonus of +1 when you reach 7 points in a skill (' Ricaricaveloce_Skill '), or 0 when you have fewer points. The attribute for the bonus is called ' Ricaricaveloce_Bonus ' <script type="text/worker"> on('change:ricaricaveloce_skill', () => { getAttrs(['Ricaricaveloce_Skill'], values => { const Ricaricaveloce_Skill = parseInt(values.Ricaricaveloce_Skill) || 0; const RicaricaveloceBonus = Ricaricaveloce_Skill >= 7 ? 1 : 0; setAttrs({ RicaricaveloceBonus: RicaricaveloceBonus }) }); }); 1)  Unofficial Pendragon 6 sheet,  a modified version of the Thierry MATTRAY Pendragon 5th ed. Sheet; counting  Passion's Court total:  In Pendragon 6 the passions are sorted in "Courts" with a total cap of 40 for each court, BUT - by rules - if your passion's value is bigger then 20, the court's cap count it ONLY as 20 anyway. GiGs have write the Fidelitas court formula, and i've added the others. The final attributes with the value of the court total capped iare called ' fidelitas_total ' [counting the passions: Homage ( attribute 'homa') 2 different Loyalty( attributes called 'loy' and 'loy2'), Fealty ( attribute 'feal')  and Duty Vassals( attribute 'duty')], ' fervor_total ',  [counting the passions: 4 differents Hate ( attributes 'hat', 'hat2', 'hat3' and 'hat4' ) and 3 differents Love ( attributes 'lov' 'lov2' and 'lov3')], ' adoration_total ' [counting the passions: Devotion ( attribute 'devo')  and Adoration ( attribute 'ador')]  and ' civilitas_total '[counting the passions: Chivalry ( attribute 'chiva'),  Hospitality ( attribute 'hos') and Station( attribute 'stati')] <script type="text/worker"> on('change:homa change:loy change:loy2 change:feal change:duty', () => { getAttrs(['homa', 'loy', 'loy2', 'feal', 'duty'], values => { let total = 0; ['homa', 'loy', 'loy2', 'feal', 'duty'].forEach(passion => { const temp = parseInt(values[passion]) || 0; total += Math.min(20, temp); }); setAttrs({ fidelitas_total: total }); }); }); on('change:homa change:hat change:hat2 change:hat3 change:hat4 change:lov change:lov2 change:lov3', () => { getAttrs(['hat', 'hat1', 'hat2', 'hat3', 'hat4', 'lov', 'lov2', 'lov3'], values => { let total = 0; ['hat', 'hat1', 'hat2', 'hat3', 'hat4', 'lov', 'lov2', 'lov3'].forEach(passion => { const temp = parseInt(values[passion]) || 0; total += Math.min(20, temp); }); setAttrs({ fervor_total: total }); }); }); on('change:devo change:ador', () => { getAttrs(['devo', 'ador'], values => { let total = 0; ['devo', 'ador'].forEach(passion => { const temp = parseInt(values[passion]) || 0; total += Math.min(20, temp); }); setAttrs({ adoration_total: total }); }); }); on('change:chiva change:hos change:stati', () => { getAttrs(['chiva', 'hos', 'stati'], values => { let total = 0; ['chiva', 'hos', 'stati'].forEach(passion => { const temp = parseInt(values[passion]) || 0; total += Math.min(20, temp); }); setAttrs({ civilitas_total: total }); }); }); </script> FINALLY, when you want to use one of those attribute in the HTML part, you cannot use: disabled="true" Instead, you can use readonly So, as an example, i will write 'fidelitas_total' in this way: <input type="number" name="attr_fidelitas_total" value="0" readonly>