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 Rollable Table Images and better prefixing rules for Roll Templates!

January 11 (7 years ago)

Edited January 11 (7 years ago)
The Aaron
Pro
API Scripter
Update v0.2.4 -- Rollable Table Item Avatar Images can be shown in the results using the ShowIcons option:
!rt[showicons] [[2t[Dice-Of-Fate] ]]


The label is the text of the Rollable Table Item name.  The label can be turned off with the IconLabel option:
!rt[showicons|iconlabel:off] [[2t[Dice-Of-Fate] ]]


If your Rollable Table Items contain references to Rollable Tables which contain images, they will be displayed in the label, so turning the label off will prevent showing those recursive results.

Additionally, you can now use %% to separate options from their arguments:
!rt[showicons%%on|iconlabel%%off] [[2t[Dice-Of-Fate] ]]
This is particularly helpful for API Command Buttons, as they would otherwise see the : and treat the command like a URL.

Finally, PrefaceUniqueWhitespace now does a better job.  Originally, it just stuffed extra spaces in front of everything, but this caused some Roll Templates to break as '     spellkey' is not the same as 'spellkey' and would fail to match properly.  Now unique keys are individually tracked and prefaced with spaces so that only the ones that actually are duplicated are prefaced. (Thanks Diana P !)


Update v0.2.0 -- Completely rewritten recursion engine taking advantage of Promises and lots of error handling. Automated fixing of API sendChat() inline rolls (in most cases). New formatting options. 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. 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)
  • PrefaceUniqueSpace -- 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)
  • ShowIcons -- Causes table items with avatars to display their image. Default: off (Boolean)
  • IconLabel -- Determines if the table items with avatars have their name as a label. Default: on 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: https://app.roll20.net/forum/post/4954818/script-update-recursivetables-now-with-direct-support-for-whispering-roll-templates-and-more


Git: https://github.com/shdwjk/Roll20API/blob/master/Re...


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.
Yummy :D once again i will be working on how this will improve my games :D 
January 11 (7 years ago)
The Aaron
Pro
API Scripter
=D  Definitely interested in feedback on the inline images.  It works for me how it is, but I could see the desire to change the size, only show them at a particular depth, group all the images at the beginning or end, not show them in the border, etc... 
January 11 (7 years ago)

Edited January 11 (7 years ago)
well i invision creating a Druid Token Table using [showicons|iconlabel:off] then have that token appear on the object layer controllable by that player for wildshapes then using the table to randomly cause my druid to surge into a form.
then based on the token i would have a sheet setup for each form and linked to those tokens as defaults.
so in essence weather he shifts per RAW or via the Surge all it takes is setting up tokens actions and he wont need to pull up his forms sheets.  

just a matter of learning token Mod i image then based on the tables roll it would swap the player token for the shapes token there by bringing up the linked sheet with the actions setup. 
January 11 (7 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Nice Aaron, Just in time for the start of my new campaign :)
January 11 (7 years ago)
The Aaron
Pro
API Scripter
=D  I needed this for the previous session of my current campaign.. wish I'd got it done sooner. =D
January 11 (7 years ago)
Diana P
Pro
Sheet Author
Again, thank you so much for getting the the PrefaceUniqueSpace option working.  My lovely treasure tables are working wonderfully!

(oh and in your main post above, under Options, that trailing s showed up at the end of PrefaceUniqueSpace again.... Pesky thing, that. :)
January 11 (7 years ago)
The Aaron
Pro
API Scripter
No problem.  Yeah, I just copy pasted the old post.. naught me!  I'll edit it, thanks for pointing it out!
January 11 (7 years ago)
Nice update, I wonder, I there an easy way to create a journal entry from a roll table, for example combining a number of tables to create an inn or magic item description?
January 11 (7 years ago)
The Aaron
Pro
API Scripter
That depends on your definition of "easy."  =D

You could certainly write a script to do that, and it would be pretty "easy".
January 11 (7 years ago)
Its always in the definition, I am sure I could give it a go
January 11 (7 years ago)
The Aaron
Pro
API Scripter
=D  I'm happy to help, feel free to ask me anything. =D
January 11 (7 years ago)

Edited January 11 (7 years ago)
Thank you, I am determined to conqure these, but I will probably need to pick your brains lol
January 11 (7 years ago)
Gold
Forum Champion
I'm excited about the "Label" feature. As far as I know -- is it correct? -- there was no way to display BOTH the picture and the words, when you roll a rollable table by default without this API script? I always had to show either the picture, or the words. There have been numerous times I wanted to show the pic with the words.

I've wanted to do the same with Card Decks. Is there another API script that does something similar for Labels on Cards?
January 11 (7 years ago)
The Aaron
Pro
API Scripter
You're probably right on that count. You might have gotten both with /roll, but the formatting kind of left something to be desired. 

For cards, I’ve got a few things. I’ve got a snippet that gives played cards a name that is their card name. I’ve also got a deck state snippet that lets the examine all the hands’ and the deck’s cards (recently expanded to support infinite decks).