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

Table Roll attacks

Hi, Im trying to set a table up for a variety of different attacks. Is this possible? Reason being is I have an ability that causes a random effect, some needing a die roll and some not. Can actions be added to a table toll? Thanks
Unfortunately I don't believe so. there may be some plugins that do so, but normally you'd simply have to manually roll once you rolled the effect from the table
1718488924
timmaugh
Forum Champion
API Scripter
Yeah, scripts can do that, but otherwise it will be a manual process. If scripts are available (game owner must be a pro sub), then post back and we can point you at potential solutions.
I can confirm the GM has a pro sub. Thanks in advanced
1718538872
timmaugh
Forum Champion
API Scripter
OK, there are three options for this that I can think of: The Metascript Toolbox Recursive Tables ScriptCards They work in different ways. I wrote the Metascript Toolbox, so I tend to use that one most often and will explain that one to you more thoroughly... but for the latter 2... Recursive Tables  (Nick O video here ) takes a direct call to the script, and when the script encounters a roll against a rollable table, it inspects the returns to see if there is another roll embedded there. If so, it continues on -- to some depth -- to continue expanding those rolls before finally outputting the final constructed message. ScriptCards is a much more like a full scripting language in its own. This one also takes a direct call to the script. You can declare a roll against a table, assign it to a variable, and then extract the value from it, allowing you to take further action on the results if there is another roll to be found. ScriptCard afficionados can probably make this version dance much better than I can explain it, so I'll leave it to one of them to jump in. For the Metascript Toolbox (a bit of an out-dated wiki entry, here ), you won't use a dedicated call to any script; you would just need to start your line with a bang (!), and then include somewhere in the line the text: {&simple} !This will output to chat [[1d20]]. {&simple} You can see I put an inline roll in there. I can also do roll templates and whispering: !/w gm &{template:default} {{name=Proof}} {{snacks=SNAAACKS}} {{roll=[[1d20]] }} {&simple} To extract the values out of a roll, you can append .value to the end of the roll. This will flatten the roll into text which the metascript loop will then detect. So if the initial roll included a roll against a rollable table which might also include another inline roll, you can do something like: !This will extract the value of the roll: [[ 1t[Encounters] ]].value {&simple} Alternately, if there were going to be multiple rolls against the table (i.e., 4t[Encounters] ), then an alternate .items syntax just got released that allows for concatenating the returns extracted from the roll. If there are any rolls in any of the returned table items, they will be expanded. !This will extract all of the items from the roll: [[ 4t[Encounters] ]].items {&simple} That .items syntax allows for different delimiters. The explanation of the syntax can be found here . If you utilize this direction and you have a rollable table item which, itself, might contain another inline roll and that second inline roll might include another roll that you need discovered, then the items in the rollable table should have each of their inline rolls marked with some usage of the .value or .items syntax. What I mean is that if you have a table with treasure, and some number of the items on the table have the added effect of "roll again from the table" to get more treasure, those items will need to have one of these syntaxes applied: 20gp and [[ 1t[Treasure]]].value 20gp and [[ 3t[Treasure]]].items(', ') That way, when those values are expanded, the new rolls are detected and rolled. Since they roll against the same table, if they encounter new rolls, THOSE rolls will be expanded, etc. (An interesting side note to using the Metascript Toolbox solution, is that it will render clickable buttons it finds in items returned from a table. So if you wanted to give a choice to the player/gm for a way to continue and ask them to choose a button, you could do that... but that is a step further than I think what you're asking for so I'll stop here and let you post back with questions, if you have any.)
Ok, that was a lot more complex than I was expecting haha, I didn't have any preconceptions so that's one me!  I haven't dabbled with script before, so a lot of this is a very foreign language to myself.  I hope you dont mind, but I'll go into more depth of what I'm trying to achieve, and get your opinion on what would be the most appropriate method? At least that way I wont waste my time looking into one of the three, and it turning out to be the least optimal form. My character is using a WIP Homebrew class, and one of the features calls upon a table. The table can be called upon for a number of reasons, so having it roll initially will be manual. However, the results have a few variety of effects. Most are description only but some require a varying number of die rolls. The die rolls are for damage, so I was also wondering if that could be implemented the same way you roll for damage after rolling to hit? I hope my description makes sense, and thanks for your time
So I'll chime in here as I am a big user of  ScriptCards  and say that I think you could use ScriptCards to roll on a table, check if the result is one of the options that requires a damage roll, rolls that damage, and then outputs all of that. That all sounds pretty straightforward to accomplish with ScriptCards. That said, I would probably say that if this is a one off and you aren't looking to automate more aspects of your game or future games, then it's probably better off to use the MetaScript option. ScriptCards is super versatile and learning its syntax can really open up a huge amount of automation options in your games but it is like learning a simple programming language and if you are only looking to automate this 1 thing and you don't already have an interest or knowledge of scripting, then it may not be something you are interested in learning. However, if you are thinking that you are curious about ScriptCards, in addition to the wiki there which has links to the Discord and Roll20 threads with examples, there are recent  Nick Olivo Youtube videos  showing him automating something with ScriptCards, and a small  tutorial series  that attempts to walk a new user through writing a ScriptCard and using its features. If you want to go down the ScriptCards route, let me know and I might be able to help you with a quick example. If you want to go down the MetaScript path, I'll say that timmaugh is better positioned to help there considering that he wrote them all.
It is just a one off thing. And I have absolutely 0 experience with scripting haha, so which route is chosen, there will be a learning process.  Im happy to delve into which ever really, but with my lack of knowledge I can only take peoples word for what is best. Which one would be the easiest for someone like myself to pick up and produce something? On another note, I did start looking at Script Cards and it certainly looked interesting  Thanks
1718551543
timmaugh
Forum Champion
API Scripter
Sure, Luke... it can be a bit daunting to begin, but soon you'll be making things dance and you'll be wondering about the next thing you can do with more scripts! Let's start with the Metascript Toolbox example. Note that with the Metascript Toolbox installed in your game, if you follow along, you can send each of these command lines through your chat and see the result for yourself. Level 1 - Basic Rolling I'm going to create a table called AttackDescriptor, and in this table I'll put a few items: You can see how 3 out of the 5 entries have an inline roll as a part of the return value. For your table, these would be the descriptions you talk about, some of which might have further rolls you want to expand (we'll look at different ways to handle the rolls in a minute). Just rolling against the table: [[1t[AttackDescriptor]]] ...you might get a return like this: ...where the roll is not detected nor expanded. Just by changing the line you send through chat to be: ![[1t[AttackDescriptor]]].value {&simple} You can "unwrap" that roll so that the included inline roll is detected and expanded: Level 2 - Rolling in a Template The {&simple} tag will work with a roll template, so if you had something of a more formatted look you can still preserve it: !&{template:default} {{name=Proof of Concept}} {{Roll=[[1t[AttackDescriptor]]].value}} {&simple} Note that the {&simple} doesn't have to be right next to the roll. It just needs to be somewhere in the line. You could even have full template parts in the item returned from the table. You would want to format them all the same (as a full template part): {{Fiery Blast=Description of the fiery blast goes here, with other [[1d20]] rolls embedded}} ... so that when you sent through a command like this: !&{template:default}{{name=Proof of Concept}} [[1t[AttackDescriptor]]] {&simple} ...you'd get a roll template with the appropriate item appended to the bottom. Level 3 - A Table Item that Rolls Against a Table Imagine the "Fiery" option of the table was structured as a "this effect plus roll again against this table". Something like: FIery [[1d20]] and [[1t[AttackDescriptor]] Well, if we rolled against the table, unpacked it with the .value syntax, and got the "Fiery" result... we'd be rolling against the same table again. This would be fine for a result where we don't have further rolls against the table, like the "Explosive" return. Sending the command: ![[1t[AttackDescriptor]]].value {&simple} ...we get... But if when we rolled against the table again, we got the same "Fiery" result (which would have us rolling against this table again ), things get a little hairy: Here, I got the "Fiery" result the first time (where it rolled a 13), then I got it again when I rolled against the table a second time (this time I got a 3, though it's hard to see with the gray-on-purple formatting), and when I had to roll against the table a third time, I got the same "Fiery" response, but now the roll syntax isn't detected, and the process ends. To fix this, let's change any table entry that includes roll against a table (where we might have a call to another table, again). We will add the .value syntax to the roll as it is written in the table item: FIery [[1d20]] and [[1t[AttackDescriptor]].value Now, if I roll a "Fiery" result, I will get the appropriate expansion of the ongoing rolls against the table until I get something other than "Fiery" (or something other than having another roll against the table -- "Fiery" just happens to be the only one I've set up this way, for now). Sending this command, again: ![[1t[AttackDescriptor]]].value {&simple} ...we now get... There are more ways to continue adding functionality (Level 4 might be rolling multiple times against the table and using .items instead of .value, etc., Level 5 might be using a button in the return so that the player has to take action and click on the button before something like damage is calculated), but for now, this should get you far enough to see how you can apply it to your setup. If you still have questions or if you want to implement something like a button to prompt for the player to take action, post back with a few examples from your table where some returns would have the extra rolls, and I can get more specific with what you'd need to do.
So I would probably recommend going down the MetaScript route as timmaugh shows above but for the sake of completeness I'll show a quick ScriptCards example. With a primary table like: And a SubTable like: Here is a quick ScriptCard that can roll on a table and output the result where it will resolve the die rolls if the entry has an inline roll like [[2d8]]. Or it can roll on a different table and use a result from the other table. !script {{ --&FeatureName|Cool Ability --&PrimaryTableName|CoolAbilityTable --#title|[&FeatureName] --&OpenRoll|[ --&OpenRoll|+[ --&CloseRoll|] --&CloseRoll|+] --&TableRoll|[ --&TableRoll|+T --&TableRoll|+# --=InitialRoll|[T#[&PrimaryTableName]] --&output|[$InitialRoll.tableEntryText] --?"[$InitialRoll.tableEntryText]" -inc "[&OpenRoll]"|>ResolveDieRollEntry;[$InitialRoll.tableEntryText];output --?"[$InitialRoll.tableEntryText]" -inc "[&TableRoll]"|>ResolveSubtableRoll;[$InitialRoll.tableEntryText];output --+Result|[&output] --:Done| --X| --:ResolveDieRollEntry|RollText;StringVariableToReturn --~_tmpPrefix|string;before;[&OpenRoll];[%1%] --~_tmpSuffix|string;after;[&CloseRoll];[%1%] --~_tmpDie|string;after;[&OpenRoll];[%1%] --~_tmpDie|string;before;[&CloseRoll];[&_tmpDie] --=_tmpRoll|[&_tmpDie] --&[%2%]|[&_tmpPrefix][$_tmpRoll.Total][&_tmpSuffix] --<| --:ResolveSubtableRoll|RollText;StringVariableToReturn --=_tmpSubTableRoll|[%1%] --&[%2%]|[$_tmpSubTableRoll.tableEntryText] --<| }} Sample output looks like: So there are a lot more things that can be done but that example above can be used and you would adjust the top lines: --&FeatureName|Cool Ability --&PrimaryTableName|CoolAbilityTable Where --&FeatureName| is the title card displayed and --&PrimaryTableName| has the name of the initial table you want to roll on. Then in your table you would add entries to the table like normal and any entry with [[XdY]] will get resolved and if you want to roll on a different table for an entry, you would use the syntax [T#NewTableName]. Basically you'd install the ScriptCard API mod in the game and use the above in a macro or character ability. So let me know if you have any questions about the above or ScriptCards in general. Like most things, there are a lot of ways to accomplish something and it just comes down to what you'd prefer or makes most sense for your situation.
Thanks to both of you for all the information provided. I imagine I’ll be able to certainly break ground with it. I’ll have a play around when I’m next on the computer. Regarding the next steps, having a button is something I would want to implement, as although some have a die roll, it’s situational to whether it needs to be applied or not. thanks as always :) 
And just to clarify, are all the API's in the toolbox required for this?
This is now the third time typing this, so forgive any mistakes as roll 20 is starting to annoy me! Twice ive hit submit and its just deleted everything But anyway, we are making good progress, but id like to add 2 further steps. A button for rolling, as although some include rolls, whether they are rolled or not is circumstantial Varying descriptions.  The format I wish to achieve is as follows Roll | Whatever is rolled Description | Description of the roll Currently the table has the name and description as one, eventually I'd like to just have the names in the table and the command line fetches the correct description based on the result, if possible.  As, having "Description =" will always display the same message regardless.  Hope this makes sense
1718655259
timmaugh
Forum Champion
API Scripter
I'll answer that last question first... are all of the Metascript Toolbox scripts necessary... You won't use every single one of these scripts for *this* message, but when you take into account the scripts that are *required* for the scripts you *will* use for the above message... you're probably talking about more than half of the Toolbox. Besides, it's not like you have x-number of script slots in your game, and by installing the Toolbox you eat up all the available slots so you can't have other scripts. If you don't use a script in a particular message, it doesn't really impact your game at all -- it doesn't slow down message processing, for instance. The unused scripts just sort of... sit there. Until you need them. Besides-the-Second, before you know it you're going to be a script maven. You're going to see more and more ways you can use scripts to make your life easier! Now, as for buttons, with the Toolbox it's pretty straightforward. Just use normal button syntax  in the rollable table item and it will render in your output (it looks best if you extract it from the roll with a .value or .items ). BTW, the only syntax I see not covered in the linked wiki article is to run a script, but that's pretty easy: [Button Label](!scriptHandle --args1 --args2) What I like to do is perform HTML substitutions on the brackets of the roll that the button will execute. This keeps the roll from executing too early (it would actually technically roll before the button made it to chat; the button would only reveal the value that had already rolled!). For this, I change the double opening and closing brackets of the inline roll. I replace [ with [ and I replace ] with ] Here is an option that would make a simple roll of extended damage after getting the Fiery return (remember that Fiery already was one that I had changed to get another item from the same table, so you'll see that syntax at the end; the new part, here, is the chat button with the roll): Fiery [Roll Damage](!
[[1d20]]) and [[1t[AttackDescriptor]]].value Similarly, here is an option that provides a button to roll again against this table. The format is the same: Explosive [Roll Again](!
![[1t[AttackDescriptor]]].value {&simple}) Here is what these two look like: That shows the first return was "Fiery," which prompted an automatic retrieval of a second item from the same table, where we got "Explosive." The syntax for these would be identical even if you were using a roll template, so I won't go into that combination (although it is how I would likely approach this usage). =D
1718655949
timmaugh
Forum Champion
API Scripter
Luke said: <SNIP> id like to add 2 further steps. A button for rolling, as although some include rolls, whether they are rolled or not is circumstantial Varying descriptions.  <SNIP> Currently the table has the name and description as one, eventually I'd like to just have the names in the table and the command line fetches the correct description based on the result, if possible.  As, having "Description =" will always display the same message regardless.  OK, hopefully my previous post will get you sorted with how to do the buttons. As for keeping the descriptions separate from the roll, we can absolutely do that. To be clear, I took what you said to mean: You are always going to have the "Description=" part of the roll, so you'd just as soon have that in the command line and then retrieve the correct info for the right side of the equal sign. Is that correct? If so, we're going to employ another of the metascripts (Muler), which will have its own syntax pattern, and we're going to want to break up the data in your table. So, before I confuse things by making a bunch of assumptions, can you share 3-4 items from your current rollable table? Having the verbiage will help me be specific in how to adapt them to make use of Muler to do what you're looking to do.
Ok I'm right back to being confused haha! Before I try and make sense, is there a way for the die part to be implemented like an attack roll? So in this instance, the 15 would be where the roll result is, description under that and the roll button being under that, like claws is in this example?
Sorry to be a pain timmaugh, but would it be possible to take this to discord or something? As not sure how the author will feel having the class information out in public as its not currently published, and I assume he will eventually
1718657766
timmaugh
Forum Champion
API Scripter
Sure... I have to step away, but ping me on the r/Roll20 server (I have the same name on that server), and I'll reply with the steps you should take, there.