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 .
×

Shaped Sheet Macro Help - MInigame Dice Rolling!

Hi guys! I am trying to make a mini game of dice for the players to place bets on during downtime, and need some help with the macros as they are a little over my head atm ._. This is what the macro is trying to do, which is totally failing atm ^^ Query Sleight of Hand = Yes / No If Yes: Roll 1x [Query Dice Size] with advantage Roll Perception Check If No: Roll 1x [Query Dice Size] Roll Perception Check I managed to get a query dice size going after around 30 minutes messing around, but now im at my limits of knowledge! :P Anyone have any ideas on how to get this one setup .. or if its even possible in 1 macro :O
1550675190
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Unfortunately, you can't do if/then logic in a macro, that requires the API. The best you could do is have it roll both dice and the player and DM only use the appropriate one.
1550688961

Edited 1550698107
By advantage do you mean they roll the same die twice and keep the higher one? If so then this should work: ?{Sleight of Hand? | Yes,  [[2d?{Die Size? }kh1 ]] | No, [[d?{Die Size? } ]] } As long as all the conditions can be determined before the roll actually happens you don't need the if/then logic to be done by the parser Edit: added a template, a dropdown for the size of the die, and the perception roll as another row. You may want to pull the perception bonus from your sheet if possible. &{template:default} {{name=Minigame}} {{Result= ?{Sleight of Hand? | Yes,  [[2d?{Die Size?| Coin, 2 | D4, 4 | D6, 6 | D8, 8 | D10, 10 | D12, 12 | D20, 20 }kh1 ]] | No, [[d?{Die Size?| Coin, 2 | D4, 4 | D6, 6 | D8, 8 | D10, 10 | D12, 12 | D20, 20 } ]] } }} {{Perception Roll= [[d20]] + [[3[perception bonus] ]]  }}
1550696155
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That's a good solution. It still puts the logical branch in the hands of the players, but does so before the roll. Nice.
Ohhh, guys this is looking awesome! Though I must be doing something wrong through, because my implementation is breaking things >.< I pasted the code in, saved it and then the popup query looked as expected. And it looks glorious! ^^ Then i reopened the macro, and it looked totally different. Weird.. so i tried to test it, and it output strange new things - even though I didn't re-save it. Example images below: Not sure why it would do that, hmmm. Any ideas? Also, whether its using the first version or the second, the output for the actual dice roll always seems to come out a little odd, whenever I select Slight of Hand Yes, the result is always 2. Whenever I select No, nothing is output to the chat window at all :O The code is glorious, but way beyond my current level of knowledge ^^ Is there anything im doing that's causing it to go awry ?
1550759625

Edited 1550759803
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Try putting the die size in brackets, so that the parser will treat the result as a number: [[2d[[?diesize| Coin, 2...D20|20 }kh1 ]]]] the part after 2d might not be resolving to 2d6 or similar. That's the first thing I'd try, anyway. EDIT: No, I see the problem. You have an extra space in your code. remove the spaces before the dies size numbers. Looking at your result, you are getting "2d 10", not "2d10". Make sure to get every space out of the expression; you also have one after the number, which parses out to a space before "kh1". As for the code changing, that's why you are putting all of the replacement codes in to begin with. Everything reverts to what it parses out to upon re-opening. It's a one-way street. The accepted convention is to save your code externally, and if you need to open it to make any changes, refresh fom that external code. (i.e. just keep the original code in a text file somewhere).
Fantastic, tyvm Keith!I had no idea abotu the code changing, but I now have a channel on discord dedicated to the snippets i import ^^ I managed to get it boiled down to the following: /w gm &{template:default} {{name=Wise Mans Gambit}} {{Wise Mans Roll= ?{Cheat with Sleight of Hand? | Yes,  [[2d?{Die Size?| D4,4 | D6,6 | D8,8 }kh1 ]] | No, [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] } }} {{Perception Roll= [[d20]] + [[0[perception bonus] ]]  }} Its working very well now! ^^ I am super happy. A final plea, and then I will leave you all alone ^^ However even if the below isn't possible, I am very happy with the current iteration! But how would I go about changing the Advantage roll, to display both rolls separately, rather than adding them together? I ee the code saying 2d? where in fact I want it to say something like: dX + dX like the perception roll does.
1550767226

Edited 1550767580
Ah, I just assumed you'd want it to roll them both and keep the higher result. To see them both separately you do this: /w gm &{template:default} {{name=Wise Mans Gambit}} {{Wise Mans Roll= ?{Cheat with Sleight of Hand? | Yes,  [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] + [[ d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] | No, [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] } }} {{Perception Roll= [[d20 ]] + [[ 0[perception bonus] ]]  }} Basically you roll the same thing twice by putting double brackets around each roll. If you put both rolls within the same set of brackets it adds them together in the result.   The plus sign is just text, you can get rid of it or put anything else you want in there
1550767244
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Just repeat your roll query. If it's worded exactly the same, Roll20 only prompts for it once, and just re-uses the result: /w gm &{template:default} {{name=Wise Mans Gambit}} {{Wise Mans Roll= ?{Cheat with Sleight of Hand? | Yes,  [[2d?{Die Size?| D4,4 | D6,6 | D8,8 }kh1 ]] [[2d?{Die Size?| D4,4 | D6,6 | D8,8 }kh1 ]] | No, [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] } }} {{Perception Roll= [[d20]] + [[0[perception bonus] ]]  }} yields:
You guys are gurus of this! It works perfectly, just as I had envisioned it ^^ Thank you both very much for all the hard work = ) I look forward to diving into the code and getting to understand it all soon. Such a great community here ^^
1550853144

Edited 1550854109
Here's a breakdown of the elements used in this macro: /w gm &{template:default} {{name=Wise Mans Gambit}} {{Wise Mans Roll= ?{Cheat with Sleight of Hand? | Yes,  [[d?{Die Size?| D4,4 | D6,6 | D8,8 }]] + [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] | No, [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] } }} {{Perception Roll= [[d20]] + [[0[perception bonus] ]]  }} /w gm <--- you probably already know this is a whisper, everything on the same line as this will be in the whisper. If you hit enter you will need to whisper again if you don't want to broadcast to the general chat &{template:default}   <-- template declaration, tells the parser what template to use. everything elsse that you want to be in the template must be on the same line as this declaration (dont press enter)     (Templates are the boxy formatting that shows up in the chat, the default one is available in every Roll20 game but many systems have more specific templates available (DnD especially)) {{name= Title }}   <--- This is the text that goes in the title box, it has to be the first thing following the template declaration (  {{name= Wise Mans Gambit }}  )  {{     }}   <--- this will start the first body row of the template, you can add as many of these as you want. If you put "some text = some info" it will split the row into two columns, the lefthand column is always bolded (its meant to be the title). If you don't split the row it will display whatever you want in bold (it thinks you only gave it a title). (  {{ Perception Roll= [[d20]] + [[0[perception bonus] ]]  }}   ) [[ ]] <--- this tells the dice parser to roll whatever is inside it ( [[ d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] ) ( [[ d20 ]] ) ( [[ 0[perception bonus] ]] ) [ some text ]  <--- when you put something in single brackets inside a roll box (double brackets) it tells the parser to ignore it, but it will still show up in the hover over. You can use this to label parts of a roll so you can keep track of where bonuses or extra dice are coming from ( 0 [ perception bonus ] ) ?{ some text | default number value }   <--- this makes a Roll Query (the popouts), you don't have to put a default number if you don't want to. As Keith said a Roll Query only needs to be answered once, every other time in the code that the exact same roll query shows up will have the same value ?{ some text | some option , some number value | some other option , some other number value }   <--- this is also a Roll Query, but it makes a dropdown instead of a text box. separate the dropdown title from the dropdown value with a comma (  ?{ Cheat with Sleight of Hand? | Yes ,   [[d?{Die Size?| D4,4 | D6,6 | D8,8 }]] + [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] | No , [[d?{Die Size?| D4,4 | D6,6 | D8,8 } ]] }  ) as for those random strings, those are HTML encoded characters: , = ' , ' | = ' | ' } = ' } ' You have to use these in Roll Queries because the parser will break if it sees these^ characters (it thinks you want to close the Roll Query or that you've put in gibberish code).  When it runs the code it replaces these with the actual character. Unfortunately when you save and close the macro it also replaces these with the actual character, so the next time you save you're back to gibberish. If you want to use complex roll queries you have to save your macro outside of roll20 and paste it in any time you want to change the macro. This is also all documented in the wiki
1550854260
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Here's another handy hint. If you save this as an ability on a character sheet, rather than a macro, the code does not replace the HTML entities, and it stays perfectly editable.  Macro Character Sheet