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

API to roll a rollable table

HI all.  I'm just starting to dive into the api scripts and I've been looking to create a script to post a wild magic outcome from a rollable table, to the gm.  I'm getting a bit cross-eyed trying to find help with this.  Wondering if someone can help. What I'm looking for is a button for a spellcaster to click whenever they cast a spell.  That rolls a d20.  If the number is 5 or less, then it signals the gm that wild magic is triggered and rolls a rollable table (Wild Magic) and displays the outcome as a whisper to the gm.  If a 6 or higher is rolled on the initial d20, it signals the gm that wild magic was not triggered. Sounds simple enough, but I can't get the table to roll. Any help would be very much appreciated! Evan
You don't need an api script for this: /w gm &{template:default} {{name=Wild Magic [ ](#" hidden null=) }} {{[0](#" hidden)= }} {{[1](#" hidden)=Wild Magic not triggered }} {{[[[1d20<5]]](#" hidden)=[[1t[your-wild-magic-table-here] ]] }} {{[0](#" hidden)=[ ](#" hidden null=) }}
That's awesome.  Thanks you Tuo!
Thanks again Tuo.  That worked great! Follow-up question.  If I set this up as a Collection macro for a spellcaster, is it possible to have the outcome of the probability die roll shown to both the caster and gm, triggered or not, but to have the outcome of the table, the wild magic effect, hidden from the caster and shown only to the gm?  A minor point, but it would help with the roleplay. For example.  Caster casts a spell and also roles this macro.  They roll a 12 and they get a message saying "Wild Magic not triggered".  The gm also gets this message.  Their next turn they cast another spell and roll the macro again, but this time get a 3.  The caster gets a message telling them that Wild Magic is triggered, but that's it.  The gm gets the same message but also gets the table outcome effect.
1743973965
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Unfortunately, messages can't be sent as truly blind. There are a few ways around this however: If the GM triggered the macro, then it could be setup so that the probability die is sent to both users, but the table roll is only sent to the gm You could hide the table roll behind a button that would then send it to the gm, but this adds some extra steps You can use an api script to make the rolls. I believe that Timmaugh's Meta toolbox scripts would let you pretty much reuse Tuo's macro with just some meta toolbox fanciness on top.
Ok.  I'll look into those and play around with it.  Thanks all for the assist!
1744036761
timmaugh
Forum Champion
API Scripter
This is also fairly trivial with the MetascriptToolbox installed: !{{(^)   ![[1d20]]   {^&template:default} ({)name=Wild Magic Roll(}) ({)Wild Roll= {&if $[[0]] < 6}Things are gettin' wild.{&else}Wild Magic not triggered.{&end}(})   /w gm {^&template:default} ({)name=Wild Magic Check(}) ({)Roll Result=$[[0]](}) ({)Table Result={&if $[[0]] < 6}@^(table.your-table-name-here.1dt){&else}Wild Magic not triggered.{&end}(}) }}