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

October 18 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.2.5 -- Added IconScale option to permit setting the size that icons are displayed at. (Thanks IrishWolf!)

!rt[showicons|iconlabel:off|iconscale:2.5em] [[2t[Fate-Dice-Composite] ]]



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: onyesytrue. false values: offnonfalse), 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)
  • IconScale -- When table icons are shown, they are restricted to the provided scale. Any valid CSS size setting will work. Default: 5em)

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/5954076/script-update-recursivetables-now-with-rollable-table-images-and-better-prefixing-rules-for-roll-templates


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.
December 15 (5 years ago)

Edited December 15 (5 years ago)

How would I go about making a table call another table with any given result? And is it possible to remove the command when rolling the same table multiple times?

edit: Also this is awesome

edit2: okay I figured it out, now my question is how would I make the result show what table it's been rolled from?


December 15 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

You'd need to prefix the row item that calls it with the table name:

Potions [[ [[1d3]]t[5e-treasure-potions]]]]]


December 15 (5 years ago)

Would there be a way to display a specific message for each individual table that is called?

So if TableA is called it shows MessageA, and if TableB is called it shows MessageB

December 15 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

You would do that on each individual row since you know explicitly which table the row is calling. 

December 16 (5 years ago)

So I'm only using [[ t[MasterTable] ]] table once, which means if I give it the prefix TableA if TableB is called it will still display TableA. I'm wondering if there is a way to dynamically change the prefix depending on what table is called. 

Thank you very much for your assistance btw!!

December 16 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

I'm assuming MasterTable is made of up rows like:

[[ [[1d6]]t[TableA] ]]
[[ [[1d3]]t[TableB] ]]

Which could be modified to:

Table A: [[ [[1d6]]t[TableA] ]]
Table B: [[ [[1d3]]t[TableB] ]]
so as to get labeling specifically when accessing a given subtable.
December 16 (5 years ago)

I am an idiot and you are a saint, I'm having massive amounts of understanding how this all functions.. thank you so much for helping me understand! Absolute legend 

December 16 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hahahaha, not a problem at all.  It seems pretty complex until you really get your head wrapped around it, then it's like "oh!"  =D

Cheers!

I use this script all the time for my PF1e campaign's loot tables, it's been such a great tool for this! I've been having difficulty using it in my PF2e campaign for some reason. Same exact version (0.2.5), and the latter campaign doesn't have any scripts that the former doesn't.

But for some reason every time I use it in this game, it turns every result into '0'.

Here's the macro and table I'm trying to use it for:

I've tried placing an extra table layer between the macro and this table, I've tried using older versions of the script, and I've tried using the command with another table that has no inline rolls at all. I get only '0' every time.

The script works fine in all other games I use it in, so I feel like I'm overlooking something obvious. I appreciate any suggestions you can offer.

January 29 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

It's this bug with Roll20: https://app.roll20.net/forum/post/6778746/api-sendchat-returns-bad-results-to-callback-with-rollable-tables-expressions-with-inline-rolls

You can try changing some of your syntax and maybe get it to work right. 

I tried removing all the inline rolls from the table, and it still doesn't work, but the whole reason to use the command is so I could use inline rolls in the table. Does the number of items in the table need to change? Do I need to move where the inline rolls are in each entry? Is there something about the command that needs to be changed? It seems to match the correct syntax.

!rt /w gm &{template:rolls} {{header=Random Alchemy}} {{desc= [[1t[P2-H4-Random-Alchemy-Table]]] }}

This syntax doesn't work either

!rt /w gm [[1t[P2-H4-Random-Alchemy-Table]]]

I even tried with a table where each entry is only a single word, all it returns is '0'.

January 30 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

That sounds pretty broken. Maybe it's something new that's wrong. If you want to PM me a link to your game and GM me I can try to figure out what's going on. 

February 27 (5 years ago)

Are you using the "Token Fate" script as well? When I had both enabled all I could get from RT was a "0" as well, but disabling "Token Fate" allowed RT to work perfectly.

Persephone said:

I tried removing all the inline rolls from the table, and it still doesn't work, but the whole reason to use the command is so I could use inline rolls in the table. Does the number of items in the table need to change? Do I need to move where the inline rolls are in each entry? Is there something about the command that needs to be changed? It seems to match the correct syntax.

!rt /w gm &{template:rolls} {{header=Random Alchemy}} {{desc= [[1t[P2-H4-Random-Alchemy-Table]]] }}

This syntax doesn't work either

!rt /w gm [[1t[P2-H4-Random-Alchemy-Table]]]

I even tried with a table where each entry is only a single word, all it returns is '0'.




Yes! We worked it out but I didn't mention the fix here. Re-adding TokenFate so that it is installed after this script in your library should allow both to function.

Terry McGinn said:

Are you using the "Token Fate" script as well? When I had both enabled all I could get from RT was a "0" as well, but disabling "Token Fate" allowed RT to work perfectly.