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

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.
1488205885
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?
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.
1488209916
The Aaron
Pro
API Scripter
Oh!  I see.   Yeah, I think I can work with that.
The Aaron said: Oh!  I see.   Yeah, I think I can work with that. Awesome!
1488753689
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.
1488759294
The Aaron
Pro
API Scripter
Ah!  Great!
1488792012
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... ;)
Does anyone have the D&D 5e DMG loot tables available as a txt file for importing with Aaron's other script?
1489006624
The Aaron
Pro
API Scripter
(If they did, they'd want to not share it here as it would be considered pirated material...)
Ah, thought it was SRD material. Oops.
1489007029

Edited 1489007057
Silvyre
Forum Champion
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.
1490501469

Edited 1490501558
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&nbsp; <a href="https://app.roll20.net/forum/permalink/4652575/" rel="nofollow">https://app.roll20.net/forum/permalink/4652575/</a>
1490501513
The Aaron
Pro
API Scripter
You'd set it up something like this: You find: [[ [[1d4]]t[Items] ]]
Thanks guys!
1490661725

Edited 1490662103
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, &nbsp;[[1t[Treasure-Hoard-CR-0to4]]] Here is the error I keep getting: For reference, the error message generated was:&nbsp;SyntaxError: Expected "[" or [ |\t] but "6" found. undefined However, if I take out the&nbsp;[[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: &nbsp;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.
1490667796
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: &nbsp;!rt /w {Whispered Name}...You find [[1t[Gems]]].
1490671301

Edited 1490671322
The Aaron
Pro
API Scripter
Like: !rt /w "?{Whispered Name}" ...You find [[1t[Gems]]]. could even expand the ?{} with your players names.&nbsp;
Hey Almighty Scriptomancer...Another question. Is there a way, or could you add a way to, do if then statements in this script? Example: &nbsp;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]]]"&nbsp;
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: &nbsp;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]]]"&nbsp; 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.
1491353712
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: &nbsp;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]]]"&nbsp; You can already do this. Setup a rollable table for your d8 with the following entries and weights: [[1t[Encounters-Table] ]] &nbsp;Weight:1 Blank &nbsp;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: &nbsp;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]]]"&nbsp; You can already do this. Setup a rollable table for your d8 with the following entries and weights: [[1t[Encounters-Table] ]] &nbsp;Weight:1 Blank &nbsp;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.