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

Add dice rolls with inputs together

1640570848

Edited 1640570889
Hello, I'm very new to coding and while I have learned a lot in the last few months I am having a challenge with trying to know how to Math properly.  What I want to do is add an input to a dice/macro formula.  {{Roll=[[1d100cs<71cf<41cf>95]] + [[?{Input|0}]]}}  = ______ }} Ideally, the sum would have the same color coding formula I have set up.  I have a pro-account and bunch of API scripts set up. Any help would be welcome.  Thank you,  David 
1641015512
timmaugh
Pro
API Scripter
Is this what you're looking for? &{template:default}[[[[1d100cs<71cf<41cf>95]] + ?{Input|0}]] {{name=Conceptis}} {{Roll 0 = $[[0]]}}{{Roll 1=$[[1]]}} Basically, that just wraps the whole of the original roll and the input in a new inline roll. I put it in a template so that you could see the output with the initial roll tip and the secondary roll tip. To just drop the entire roll in a chat message (without breaking out Roll 0 vs 1 like this), you would only have the roll tip that condensed the first roll's information into a simple value.
1641022026

Edited 1641022066
GiGs
Pro
Sheet Author
API Scripter
Can you describe how the roll is supposed to work? I ask because I'm wondering if the Input should be added to the d100 before checking against the 71/41/etc, or should the Input be added to the 71/41/etc. Also something you should be aware of: in roll20, the < sign actually means "less than or equal to" or <=. So I'm guessing 1d100cs<71 should be 1d100<70. Finally you have cf at <41 and >95: are you supposed to be getting critical failure colours both at low rolls and high rolls?
>> Can you describe how the roll is supposed to work? I ask because I'm wondering if the Input should be added to the d100 before checking against the 71/41/etc, or should the Input be added to the 71/41/etc. >> I'm trying to use it for my Marvel FASERIP games where the INPUT represents Karma and it is added to the d100 roll, ideally with colored results Blue, Green, Yellow, Red. Blue being critical failure and Red being Critical success. Thank you for the help. I know others have tried FASERIP macros, but I don't think I have see any that add Karma to the rolls.  This is a huge stepping stone though
>> should the Input be added to the 71/41/etc. >> Yes, please. and Thank you.
1641074291
GiGs
Pro
Sheet Author
API Scripter
I dont know the FASERIP mechanics, so can you describe it without reference to roll20? Imagine I'm a new player at your table and you are explaining how rolls work. By the way, you cant get 4 colours without using a custom script, though you are a Pro user so a custom script is possible (ScriptCards might be able to handle the roll). If you are using a standard roll, I think you need to apply the modifier to the target numbers. D100 + modifier vs 70 is the same as D100 vs 70 - modifier, so you could do this: [[1d100cs<[[70-?{Input|0}]]cf<40cf>96]] and if you also need to modifier the 40 and 96: [[1d100cs<[[70-?{Input|0}]]cf<[[40-?{Input}]]cf>[[96-?{Input}]] ]] Finally, if you want to show both the roll total (D100+Input), and show the colour, you have to use a convoluted method to show it, like so: &{template:default}[[ [[1d100cs<[[70-(?{Input|0})]]cf<[[40-(?{Input})]]cf>[[96-(?{Input})]] ]] + ?{Input}]] {{roll=$[[3]]}} {{Result=$[[4]]}} A custom API script will do a better job and can show the 4 colours properly, but we'd need a complete description of how the mechhanics work to implement that.
1641075086
timmaugh
Pro
API Scripter
I'm looking at this more, and I'm running into a problem... the <41 and >95 are tripping up the parser. You aren't getting the equation you think you're getting. Basically, the order of the < ... > makes the chat parser think it has encountered an html tag -- and since your particular tag (41cf) isn't whitelisted, it gets eaten. Run this and look at the roll tip: [[1d100cs<71cf<41cf>95]] You're left with only the 71 and 95 as boundaries. Someone else can probably say better whether you can use multiple failure thresholds, but I tried reordering the input of the markers to see if I could avoid having the chat parser think it had encountered a tag. That broke the parser. I can produce the information you're looking for with metascripts, if that's an option. Here is an example: !&{template:default} [[1d100]]{{name=Conceptis}} {{{&if $[[0]].value >=  [[95 + ?{Input|0}]].value || $[[0]].value <= [[41 + ?{Input}]].value}FAILURE!{&elseif $[[0]].value <= [[71 + ?{Input}]].value}SUCCESS!{&else}NORMAL{&end} =$[[0]]}}{{BOUNDARIES=}}{{Failure=<=$[[2]].value, >=$[[1]].value}}{{Success=<=$[[3]].value}}{&simple} That produces this output when I give an "Input" of 14... I included the boundaries so that I could be sure that my testing was working. You might find them informative, or not. In my example, the input modifies all of the thresholds in the same direction. I find that mechanic hard to understand as an implementation of "karma"... I would think it the boundaries would expand/contract based on how difficult the karma was making a given attempt. In other words, it might be subtracted from the lower boundary but be added to the upper boundary. You should be able to spot where the Input query is being added to each boundary in the above example and modify accordingly if this isn't exactly correct. To pull this off, you'd need ZeroFrame and APILogic installed.
1641076873
GiGs
Pro
Sheet Author
API Scripter
Good point. I commented earlier about the weirdness of the cf having a low and a high target, but forgot to test it.