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

[Recursive Table] How to prevent duplicates ?

Hi, I've been tinkering with Recursive Table a bit, and I came across a problematic issue : Recursive table, by default, picks random items in a rollable table. But he can pick the same thing twice.. Example, running down this : !rt /w gm [[8t[treasurechest]]] Could return this : Sword, Sword, Sword, Sword And I'd want to return only non-duplicates tables, like : Sword, Crown, Bow, Jacket Is it possible ?
1671737133
The Aaron
Roll20 Production Team
API Scripter
Hmm.  Not built in, but it's a feature I could add, though it would require a bit of rework on the way rolls are handled.
1671737217

Edited 1671737236
I see, would you be able to add it in the coming weeks or if not, do you have any alternative ideas I could use to obtain this result ?
1671741435
David M.
Pro
API Scripter
Also could be handled in Scriptcards by creating something like a RollOnTable function called in a loop and checking for duplicates until some kind of totalValidRolls variable is reached.
1671741838

Edited 1671742048
David M.
Pro
API Scripter
Here's a scriptcard example for a set of unique Eye Rays for a Beholder. Queries for number of rolls to make in a table called "EyeRays" and loops until all rolls are unique. Note that as the number of rolls approaches the number of items in the rollable table, there is an increased chance of getting a timeout error.  !scriptcard {{ --#title|Beholder Rays --#debug|0 --:Initialize Roll Vars| --=NumRolls|?{NumRolls?|3} --=RollCount|0 --&ValidResults| --:Loop| --=RollCount|[$RollCount] + 1 -->RollTable| --+[$RollCount]|[$Roll.tableEntryText] --?[$RollCount] -lt [$NumRolls]|Loop --X| End macro --:FUNCTIONS| --:RollTable| --:RollLoop| --=Roll|[T#EyeRays] --?"[&ValidResults]" -inc "[$Roll.tableEntryText]"|Loop --&ValidResults|+[$Roll.tableEntryText] --<| }}   
More than half of the time I only get 3 or 2 rolls even tho I put --=NumRolls|4 Any idea why ?