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

Macro or script to generate random DC for pick locks and other things

Hi, I'm working on a macro to generate random chests that players can find and try to open and loot (that is always an exciting thing). So, first of all I'd like to generate the material of which the chest is made (wood, bone, stone, iron, mithral etc.). Depending on the random material (through rollable table) outcome I would like to have a AC, HPs, DC to broken or pick the lock (I think that broken the lock should be something like pick the lock DC + 1d5). Then, I'm trying to use recursive tables to get the content of the chest. So, as a Plus subscriber I've written this: /w gm &{template:default}{{name=**Random Chest**}}{{DC to open =[[d30]] + 5 To break}} {{|<10|= CA [[10]]; Low quality wood; [[1]] HP}} {{|10 - 13|= CA [[15]]; Wood/Bone; [[3]] HP}} {{|14 - 16|= CA [[17]]; Stone; [[2d6]] HP}} {{|17 - 20|= CA [[19]]; Iron/Steel; [[3d6]] HP}} {{|21 - 25|= CA [[21]]; Mithral; [[3d6]] HP}} {{|26 - 30|= CA [[23]]; Adamantine; [[4d6]] HP}} This is actually a draft. Brackets on raw numbers are just to higlights purpose. In fact, with this method I would have to search for the DC to open die result and depending on it check the other stats for my random chest. For example: DC to open 22 I'm in the mithral range (21 / 25) so CA would be 21 and HP's are 3d6 (I will add even hardness from DMG). Break the lock is 22 + 5 Honestly this is a mess. I'm sure I could use recursive table (I got a PRO sub) to achieve my goal. Something like: !rt [[1t[material]]]                              with a material table that would include the stats for that particular material. Any tip or suggestion to made things neat and clear?
1500993640
The Aaron
Pro
API Scripter
You can definitely use RecursiveTable for that.  One thing that might not be obvious is you can include multiple template rows in a single table item: {{AC=[[16+1d4]]}} {{Material=[[ 1t[[IronOrSteel]]]}} {{HP=[[3d6]]}} When working with templates, you probably want to use: !rt[PrefaceUniqueSpace|1] /w gm &{template:default}[[ 1t[RandomChest] ]] to make sure that multiple Roll Template keys are treated uniquely.
Ok, I'll give a try to it, thanks
I've just started to work with recursive tables. What's the function of the first part of the code you posted? !rt[PrefaceUniqueSpace|1]
1500996854
The Aaron
Pro
API Scripter
Normally if you had this: &{template:default} {{Monster=Frogman}} {{Monster=Snakeman}} {{Monster=Pigman}} {{Monster=Bearman}} You'd only get the effect of: &{template:default} {{Monster=Bearman}} because the Monster key is overridden. Adding [PrefaceUniqueSpace|1] onto the !rt command causes it to make each key unique, effectively changing it like this: &{template:default} {{Monster=Frogman}} {{ Monster=Snakeman}} {{ Monster=Pigman}} {{ Monster=Bearman}} The spaces make the keys unique, but the visual display is not affected as spaces are compressed by HTML.
Yeah I've understood what do you mean, but I'm really noob with scripts so I'm not able to get a good result. I've two diferent tables. First one is for the chest, with CA, material, DC to pick the lock etc. The second is for randomize the content. Max number of objects player can find is 15 objects, minimum 0, with the possibility of finding a treasure hoard with another level of recursion. The macro does its job, but text formatting is terrible and I can't whisper to gm the result. Here is what I get: would you mind to write a very little code using the same tables you see in the screenshot with a default template and the /w gm?  it would be helpful to understand how to manage templates with recursive tables. Thanks very much in advance. here is the macro: /w gm !rt [[1t[RANDOM-Materiali-Scrigni]]] !rt [[[[d16 - 1]]t[RANDOM-Scrigno]]]
1501000228
The Aaron
Pro
API Scripter
Try this: !rt /w gm &{template:default} {{name=Chest}} [[1t[RANDOM-Materiali-Scrigni]]] !rt /w gm &{template:default} {{name=Contents}} {{Found=[[[[d16 - 1]]t[RANDOM-Scrigno]]]}} It looks like the first table roll is returning Roll Template Rows ({{Mateiale = Mithral}} ,etc), so I just added the whisper and the template name to it.  The second is just returning the list of goods, so I wrapped that one in a Roll Template Row ( added "{{Found= }}" around it).  I also added two names.  You could also combine these like this: !rt /w gm &{template:default} {{name=Chest}} [[1t[RANDOM-Materiali-Scrigni]]] {{Contents=[[[[d16 - 1]]t[RANDOM-Scrigno]]]}}
Briliant! Thanks, you are super kind
 Just wonder why first table is not included in braces neither in the first macro nor in the second, while second table is inside braces
1501002677
The Aaron
Pro
API Scripter
because the content of the first one comes back with the brackets.  You might say that it is "Roll Template Aware", whereas the second just comes back with raw text, so needs to be wrapped to fit into the Roll Template.  
Alright, thanks for the explanation. What an elegant screenshot! :D
1501003445
The Aaron
Pro
API Scripter
=D  It's from an App named Skitch.  Has nice shortcut keys, tools, and drag/drop behavior.