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

[Script Update] RecursiveTables -- Now with direct support for Whispering Roll Templates and more!

1492985782

Edited 1492985818
The Aaron
Pro
API Scripter
Update v0.2.0 -- Completely rewritten recursion engine taking advantage of Promises and lots of error handling. &nbsp;Automated fixing of API sendChat() inline rolls (in most cases). &nbsp;New formatting options. &nbsp;Thanks Scott C. for the ground work on the RollTemplate fix! RecursiveTable provides a way to expand the results of Rollable Tables which have inline rolls within them. Now with options and support for whispering Roll Templates. &nbsp;When using Rolltemplates, your message must have at least one {{ that in not coming from a Rollable Table. When using the PrefaceUniqueSpace option, be sure your {{name=something}} is first. Commands !rt[options] [--help| ... ] Performs all inline rolls, then continues to expand inline rolls (to a default maximum depth of around 10). --help -- Shows the Help screen. ... -- Anything following !rt will be expanded, then sent to to the chat. Options These are inline settings to adjust how the rolls are put together. Options are specified in [ ] right after the !rt : !rt[delimiter:-|maxdepth:20] something Options are separated with the verticle pipe symbol ( | ) and have an optional argument separated by a : . Omitting the argument causes true to be used for switch options, or the default value. All Options are case insenstive. Options are one of 3 types: Number (any integer), Boolean (true values: on , yes , y , true . false values: off , no , n , false ), or text (any value except ] , use \| for | ) MaxDepth -- Specifies the number of recursions to perform. Default: 10 (Number) Delimiter -- A string of text to put between table items. The special value BR will cause html line breaks to be used. Default: , (String) DropEmpty -- Causes empty table items to be dropped before joining with the delimiter. Default: on (Boolean) Sort -- Causes table items to be sorted before being joined by the delimiter. Note that this happens at a single layer of recursion, so if you have table items made of of lists of table items, the sorting will only be at each level. Default: off (Boolean) PrefaceUniqueSpaces -- Causes the final message to have a unique number of spaces inserted after each {{ . This is useful if you're building Roll Templates and might have multiple lines with the same label. Default: off (Boolean) Examples Basic usage, whispering treasure to the gm: !rt /w gm [[1t[treasure-table]]] Whispering a roll template: !rt /w gm &{template:default}{{treasure=[[1t[treasure-table]]]}} Whispering a roll template, with each item on a separate line: !rt[Delimiter:BR] /w gm &{template:default}{{treasure=[[1t[treasure-table]]]}} Whispering a roll template, with each item on a separate line, with empty results replaced by Nothing: !rt[Delimiter:BR|EmptyDefault:Nothing] /w gm &{template:default}{{treasure=[[1t[treasure-table]]]}} Whispering a roll template, with each item on a separate line, with a table that is returning {{label=values}} : !rt[Delimiter:BR|PrefaceUniqueSpace] &{template:default}{{name=Treasure Bundles}}[[5t[treasure-bundle]]] Prior Thread:&nbsp; <a href="https://app.roll20.net/forum/permalink/2845333/" rel="nofollow">https://app.roll20.net/forum/permalink/2845333/</a> Git:&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/Re" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Re</a>... Support my work on If you use my scripts, want to contribute, and have the spare bucks to do so , go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free! Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
1492988343
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Awesome Aaron, looks much cleaner and simpler than the rough concept I did up. Can't wait to integrate this into my campaign.
1492993945
The Aaron
Pro
API Scripter
I didn't bring over the table roll offsets yet, do you still use those?
1492994863
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I have one thing that I use them for, but not as much as I thought I would.
So, is there any way to keep the critical success formatting of a roll with this script?&nbsp; I'm using this macro: !rt /w GM &{template:5e-shaped} {{title=Random Encounters}} {{roll1=[[1d6cs&lt;1cf&gt;2]] }} {{roll2=[[1t[?{Table?|Daytime-Encounters|Nighttime-Encounters|Marsh-Encounters|Laughing-Hollow-Encounters|MistyWoodEncounter|HighMoorEncounter|NagaDungeon1|NagaDungeon2}] ]] }} It works fine now with the roll template, but the red or green highlights around "roll1" disappear.&nbsp; That's the roll to determine if an encounter has occurred, the second roll on the table is what the encounter is.&nbsp; Is that a limitation of the script?
1493028806
The Aaron
Pro
API Scripter
That is a limitation. Instead, I'd suggest having a table with 2 entries: weight 5: {{roll1=No Encounter}} weight 1: {{roll1=[[1t[?{Table?|Daytime-Encounters|Nighttime-Encounters|Marsh-Encounters|Laughing-Hollow-Encounters|MistyWoodEncounter|HighMoorEncounter|NagaDungeon1|NagaDungeon2}] ]] }} then roll on it: !rt /w GM &{template:5e-shaped} {{title=Random Encounters}} [[1t[encounter-check]]] That will give you the encounter if it's rolled, or No Encounter if it isn't.&nbsp;
The "No Encounter" part worked fine.&nbsp; I just kept rolling until an encounter came up, and I "encountered" this error:
1493045533
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, not sure if it's the cause, but the roll query won't work because they aren't triggered by script sent messages. This could have caused the error because the script couldn't find a table named ?{Table?|Daytime-Encounters|...
1493045987
The Aaron
Pro
API Scripter
Oh, yeah, missed that query.. was doing that on my phone. So, make multiple entry tables: !rt [[ 1t[?{Table|Daytime-Encounter-Check|Nighttime-Encounter-Check|Marsh-Encounter-Check|Laughing-Hollow-Encounter-Check|MistyWood-Encounter-Check|HighMoor-Encounter-Check|Naga-Dungeon1-Check|Naga-Dungeon2-Check}] ]] Each of those -Check tables would have 2 entries: {{roll1=No Encounter}} {{roll1=[[Daytime-Encounters]]}} weighted appropriately.&nbsp; That's a bit more work on the setup, but gives you more control on the chance of encounters, if you want.
Hm...that's not working either.&nbsp; Getting this error in chat: (From RecursiveTables): An error occured parsing this roll: {{roll1=[[Naga-Dungeon1]]}} Error: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "N" found.
1493050418
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Guess that's supposed to roll a table, but you're missing the proper formatting: [[xt[tablename] ]]
1493050556
The Aaron
Pro
API Scripter
Yup, should be: {{roll1=[[ 1t[Naga-Dungeon1] ]] }}
1493050593
The Aaron
Pro
API Scripter
(But hurray for the new error output, so much easier to track this down than it was before!)
Yep, that did it.&nbsp; Thanks guys!
1493059522
The Aaron
Pro
API Scripter
Cool! &nbsp;Happy Rolling!
This is fantastic news! &nbsp;I just tested the new script and my treasure rolls whisper in a template just like I wanted them to. &nbsp;Thanks!
1493390487
The Aaron
Pro
API Scripter
Sweet. :). Happy Rolling!
I was trying to make my tables into command buttons so that I can have one macro to call up my rollable tables and then I can just have rt whisper me the results, but on my proof of concept run it performed strangely My command was: [test](!rt [[1t[IoD_Island_and_Peninsula_Encounters]]]) Is there something else I need to do?
1493395177
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
API command buttons don't play well with inline rolls (the roll gets changed to be the contents of the hover text rather than the actual result. HTML encode the inline roll brackets and you'll be good to go: [test](!rt &amp;#91;&amp;#91;1t[IoD_Island_and_Peninsula_Encounters]&amp;#93;&amp;#93;)
1493395730

Edited 1493395763
That solved it! Thank you very much! &nbsp;I always get confused when I do or don't need to use the HTML code for my macros and abilities lol.
1493537048

Edited 1493537065
If I put icons in my rollable tables and use this format for the table "!rt &{template:default}{{treasure=[[1t[treasure-table]]]}}" is there anyway to display the icons to the side of the item name?
1493550787
The Aaron
Pro
API Scripter
No, but that's a fantastic idea. Where would you want them shown, to the right or left? And how large?
To the left and not really large just a picture to go with the item.&nbsp;
1493604516
The Aaron
Pro
API Scripter
I imagine I can do something along those lines. :)