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

[5e] Need help with Custom Wild Magic Table surges

Hello everyone! I'm trying to create a rollable table for a Wild Magic Table surge, that works like this: First, you roll a 1d20. If the roll is between 1-5, you roll a d100 on the bad-wild table. If the roll is between 6-15, you roll a d100 on the neutral-wild table. If the roll is between 16-20, you roll a d100 on the good-wild table. The macro I've come up with is the following: &{template:5e} {{title=Wild Magic Result}} {{subtitle=Rolling Wild Magic...}} {{roll1=[[@{selected|d20} &{tracker}]]}} {{roll1name=Wild Magic Roll}} {{result1=[[@{roll1} < 5 ? 1t[bad-wild] : (@{roll1} > 16 ? 1t[good-wild] : 1t[neutral-wild])]]}} {{result1name=Result}} The thing is, I keep having the TypeError: Cannot read properties of undefined (reading 'substring') Thanks in advance!
The Aaron
Roll20 Production Team
API Scripter
The ternary operator does not work in Roll20 rolls.  This is easiest to do with access to the Mod (API) Scripts feature from a Pro account.  With that, you can use the RecursiveTable API script to set up tables that call other tables to produce a result, or use one of the API scripts that handles Wild Magic already. Without access to the API, you have fewer options. You can make it work by creating 4 rollable tables named thusly: wild-magic1 wild-magic2 wild-magic3 wild-magic Table wild-magic should have 3 entries with the following names and weights: name: 1  weight: 5 name: 2 weight: 10 name: 3 weight: 5 wild-magic1 contains all the bad wild magic, wild-magic2 contains all the neutral wild magic, wild-magic3 contains all the good wild magic.  You can then do the roll like this: [[1t[wild-magic[[1[wild-magic]]]]]] This works by building the table name to roll on (wild-magic1, wild-magic2, wild-magic3) based on the result of the roll to wild-magic (a 1, 2, or 3 with the appropriate weights). The names don't matter so much, so long as the tables being selected from all have the same name and vary by a number at the end, and the table with the weights has the right numbers in it.  It must be numbers, it won't work with words like "good" or "bad".
Hey! thank you very much!