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] RecursiveTables -- Expands Inline Rolls in Rollable Table Results

February 27 (8 years ago)
Hey The Aaron, O Great Scriptomancer, I have a quick question for you. Is there a way to call a previous roll with the script? Or is there a way to build one in, with a future build? Example, you make a roll [[1t[Keys]]] and you want to reference the chosen key from the list further on in the script like so: The (*chosen key*) will open the [[1t[DoorTyp]]].

Just wondering if this is possible.
February 27 (8 years ago)
The Aaron
Pro
API Scripter
There aren't but back references, but there could be, probably...  can you give a bit more description of what you mean?
February 27 (8 years ago)
Alrighty, so in a couple of my scripts that I'm working on for the tables, I've had to come up with some interesting work-arounds as far as wording the descriptive text. There are times where it would be good to have the function to call a previously rolled table response to make the text a little less convoluted. Like in my example above, the players will find a key, but that key will only open a specific door. I put part of the text for the script in a whisper to myself, and some of it in common chat so the players can see part of the fun. So with the example, I will whisper to myself the key and corresponding door, but I will have part of the text telling the players that they found a key, which in essence would be the same key I had rolled in the whisper.
February 27 (8 years ago)
The Aaron
Pro
API Scripter
Oh!  I see.   Yeah, I think I can work with that.


February 27 (8 years ago)

The Aaron said:

Oh!  I see.   Yeah, I think I can work with that.



Awesome!
March 05 (8 years ago)
The Aaron
Pro
API Scripter
There is a depth problem with the expansion where Roll20 stops expanding. :/ it's on my list to investigate. 

The Aaron said:

There is a depth problem with the expansion where Roll20 stops expanding. :/ it's on my list to investigate. 

I figured it out. I forgot to add the !rt. That's why I deleted the last post.
March 06 (8 years ago)
The Aaron
Pro
API Scripter
Ah!  Great!
March 06 (8 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter

The Aaron said:

There is a depth problem with the expansion where Roll20 stops expanding. :/ it's on my list to investigate. 

But still do this... ;)
March 08 (8 years ago)
Does anyone have the D&D 5e DMG loot tables available as a txt file for importing with Aaron's other script?
March 08 (8 years ago)
The Aaron
Pro
API Scripter
(If they did, they'd want to not share it here as it would be considered pirated material...)
March 08 (8 years ago)
Ah, thought it was SRD material. Oops.
March 08 (8 years ago)

Edited March 08 (8 years ago)
There may be some tables within a linked google doc within the first post of this thread.
LOL- I made some. And pushed the script in doing so. Will see if that funky error goes away when Aaron releases the rewrite. I don't have a problem sharing it so long as we can come up with a way to prove you legally owned a copy of DMG! Maybe a pic of you with your dm guide and a copy of your receipt along with a newspaper with today's date?

Never considered the fact that while sharing the code for Scott and Aaron to trouble shoot would be pirating! I am a pastor, the headlines would be epic. I am positive they would include Pastor, pirate, and possibly dungeons and dragons.....     :)
Hey The Aaron (Almighty Scriptomancer) I have yet another question for you. How would you perform a roll on a table that is asking to roll another table, but needs to roll say d4 times?

Example: You find [[1d4]] Items. Where Items is another table.
March 26 (8 years ago)

Edited March 26 (8 years ago)
It would be along the lines [[[[1d4]]t[TableName]]] but there might be an issue with tables nested further. Not sure if it's still the case but I had this problem https://app.roll20.net/forum/permalink/4652575/
March 26 (8 years ago)
The Aaron
Pro
API Scripter
You'd set it up something like this:
You find: [[ [[1d4]]t[Items] ]]

Thanks guys!
March 28 (8 years ago)

Edited March 28 (8 years ago)
Alright, so I'm running into more problems. Here is the code I'm using:

!rt /w gm You find, [[6d6*100]] cp, [[3d6*100]] sp, [[2d6*10]] pp,  [[1t[Treasure-Hoard-CR-0to4]]]
Here is the error I keep getting:

For reference, the error message generated was: SyntaxError: Expected "[" or [ |\t] but "6" found.
undefined
However, if I take out the [[1t[Treasure-Hoard-CR-0to4]]] part, this is what I get:

You find, 2500 cp, 600 sp, 110 pp
What am I missing/doing wrong?

EDIT: Nevermind, I figured it out. I went through and double-checked the spacing on the tables. It was off a little. Think I just needed to put my problem in words to get that "aha" moment.
March 28 (8 years ago)
The Aaron
Pro
API Scripter
Yup, there's a bug in the inline dice parser for the API. I really should write a preparer to fix it...
Hey Aaron, another question for you oh Mighty and Powerful Scriptomancer. How would you do a recursive roll that whispers to someone but you're not sure who to whisper to?

Example: !rt /w {Whispered Name}...You find [[1t[Gems]]].
March 28 (8 years ago)

Edited March 28 (8 years ago)
The Aaron
Pro
API Scripter
Like:
!rt /w "?{Whispered Name}" ...You find [[1t[Gems]]].
could even expand the ?{} with your players names. 
Hey Almighty Scriptomancer...Another question. Is there a way, or could you add a way to, do if then statements in this script?

Example: In one of my campaigns, if I roll a 1 on a die, then I would have to roll on a table for an encounter. Would you be able to perform an if/then statement like this: "If [[d8]] = 1, then [[1t[Encounters-Table]]]" 
April 05 (8 years ago)

Arthur B. said:

Hey Almighty Scriptomancer...Another question. Is there a way, or could you add a way to, do if then statements in this script?

Example: In one of my campaigns, if I roll a 1 on a die, then I would have to roll on a table for an encounter. Would you be able to perform an if/then statement like this: "If [[d8]] = 1, then [[1t[Encounters-Table]]]" 
You could build a table that has one entry for the tables you want to roll and then one entry (weight 7) for no encounters.
April 05 (8 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Arthur B. said:

Hey Almighty Scriptomancer...Another question. Is there a way, or could you add a way to, do if then statements in this script?

Example: In one of my campaigns, if I roll a 1 on a die, then I would have to roll on a table for an encounter. Would you be able to perform an if/then statement like this: "If [[d8]] = 1, then [[1t[Encounters-Table]]]" 

You can already do this. Setup a rollable table for your d8 with the following entries and weights:

[[1t[Encounters-Table] ]]  Weight:1

Blank  Weight:7

Of course if you have other possibilities, then you can change what is in weight 7 or have several entries with less than weight 7.

Scott C. said:

Arthur B. said:

Hey Almighty Scriptomancer...Another question. Is there a way, or could you add a way to, do if then statements in this script?

Example: In one of my campaigns, if I roll a 1 on a die, then I would have to roll on a table for an encounter. Would you be able to perform an if/then statement like this: "If [[d8]] = 1, then [[1t[Encounters-Table]]]" 

You can already do this. Setup a rollable table for your d8 with the following entries and weights:

[[1t[Encounters-Table] ]]  Weight:1

Blank  Weight:7

Of course if you have other possibilities, then you can change what is in weight 7 or have several entries with less than weight 7.

Ah, I didn't think of that. Thank you Scott, I will check that out.