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

Is there a way to make a macro to roll on a table, that instead of displaying the numbered result, it displays words you assign to a range of numbers?

1682165688

Edited 1682168956
Arc
Pro
For the D&D 5E by Roll20 sheet. Doesn't have to be a macro, could also be an API script if it has to be. For example, I want them to roll a d100 for gathering in a Forest or a Desert, etc. The table looks something like this: d100 DC Forest Desert Grasslands Marsh Mountains 01-10 - Nothing Nothing Nothing Nothing Nothing 11-20 10 plant 1 rock 1 plant 1 plant 1 rock 1 21-40 10 plant 2 rock 2 plant 2 plant 2 rock 2 41-50 10 plant 3 rock 3 plant 3 plant 3 rock 3 51-60 10 plant 4 rock 4 plant 4 plant 4 rock 4 61-70 10 plant 5 rock 5 plant 5 plant 5 rock 5 71-80 10 plant 6 rock 6 plant 6 plant 6 rock 6 81-90 10 plant 7 rock 7 plant 7 plant 7 rock 7 91-95 10 plant 8 rock 8 plant 8 plant 8 rock 8 96-00 10 plant 9 rock 9 plant 9 plant 9 rock 9 The macro or whatever can do this doesn't have to be all of this, it can just be one column. Let's say they press the Forest macro button and get an 84. The macro would then tell them they got a plant 7. Any help would be great! And sorry if something like this already exists, I couldn't find something like this specifically. Thank you for reading! Edit: If possible, I'd love for it to show the result on the d100 next to the word result.
1682170699
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yes, use the rollable tables . Just make sure each entry starts with a non number non space character.
1682171171

Edited 1682171463
David M.
Pro
API Scripter
EDIT: ninja'd by Scott! Both methods are valid. The advantage of the Scriptcard is that you can edit everything in one place and could have more control of the output formatting. The advantage of the rollable table method would be that you could more easily change the probabilities/weighting of each terrain table. As written below the indexing uses the same weighting for all. You could probably do this by making a bunch of weighted rollable tables named "<Terrain>GatheringTable" and using a query to dynamically call the appropriate table, but that's a lot of setup. Optionally, here's a quick and dirty  Scriptcard that gives you the results you want. Populates an array of values for each Terrain type. The index of the array is determined using conditionals based on the die roll, and the results are printed to chat. Just used the default scriptcard formatting, but that can be easily changed. !Script {{ --#title|Gathering Lookup Example --&terrain|?{What terrain?|Forest|Desert|Grasslands|Marsh|Mountains} --#leftsub|Terrain Type: [&terrain] --=roll|1d100 --~|array;define;ForestArray;Nothing;ForestPlant1;ForestPlant2;ForestPlant3;ForestPlant4;ForestPlant5;ForestPlant6;ForestPlant7;ForestPlant8;ForestPlant9; --~|array;define;DesertArray;Nothing;DesertRock1;DesertRock2;DesertRock3;DesertRock4;DesertRock5;DesertRock6;DesertRock7;DesertRock8;DesertRock9; --~|array;define;GrasslandsArray;Nothing;GrasslandsPlant1;GrasslandsPlant2;GrasslandsPlant3;GrasslandsPlant4;GrasslandsPlant5;GrasslandsPlant6;GrasslandsPlant7;GrasslandsPlant8;GrasslandsPlant9; --~|array;define;MarshArray;Nothing;MarshPlant1;MarshPlant2;MarshPlant3;MarshPlant4;MarshPlant5;MarshPlant6;MarshPlant7;MarshPlant8;MarshPlant9; --~|array;define;MountainsArray;Nothing;MountainRock1;MountainRock2;MountainRock3;MountainRock4;MountainRock5;MountainRock6;MountainRock7;MountainRock8;MountainRock9; --=roll|1d100 --?[$roll] -le 10|&index;0 --?[$roll] -ge 11 -and [$roll] -le 20|&index;1 --?[$roll] -ge 21 -and [$roll] -le 40|&index;2 --?[$roll] -ge 41 -and [$roll] -le 50|&index;3 --?[$roll] -ge 51 -and [$roll] -le 60|&index;4 --?[$roll] -ge 61 -and [$roll] -le 70|&index;5 --?[$roll] -ge 71 -and [$roll] -le 80|&index;6 --?[$roll] -ge 81 -and [$roll] -le 90|&index;7 --?[$roll] -ge 91 -and [$roll] -le 95|&index;8 --?[$roll] -ge 96|&index;9 --&result|[@[&terrain]Array([&index])] --+Die Roll|[$roll] --+Result|[&result }} Example output:
1682171767

Edited 1682238148
GiGs
Pro
Sheet Author
API Scripter
I think the only way to do this satisfactorily is with a script, as described above. You cant do it with standard macros.
One thing to note is that only the ScriptCards answer can also show the d100 result since Rollable tables don't take in numbers. There is a new suggestion (still struggling for votes) that would let you use rollable tables with actual rolls:  Rollable tables with modifier/advantage/as lookup . This suggestion would give significantly more roll control for tables and if that interests you considering adding your voice and vote to it.
1682179270

Edited 1682179323
timmaugh
Forum Champion
API Scripter
And, like a kid running alongside the bus they just missed, with none of the other kids alerting the bus driver, don't forget Muler . =D Muler can also do this, with the benefit of returning the information to the command line (for other scripts to use) or (with the help of ZeroFrame) outputting to chat. Muler can use mules you set up in a character ability, or it can do what RainbowEncoder just mentioned -- rolling against a rollable table with a value (like a die result)... which can allow for adjustments/modifiers to the roll. If you want to use a mule ability, you'd format each column as a mule itself. For instance, on the character PlantMule in an ability named Forest, you'd have: 1-10=None 11-20=Plant 1 21-40=Plant 2 41-50=Plant 3 51-60=Plant 4 61-70=Plant 5 71-80=Plant 6 81-90=Plant 7 91-95=Plant 8 96-100=Plant 9 Then you could get that with a muler construction like this: get.PlantMule.Forest.[[1d100]].value/get And output it in a template like this: !&{template:default}{{name=Plant Check}}{{Roll=[[1d100]]}}{{Result=get.PlantMule.Forest.$[[0]].value/get}}{&simple} Here is that command run a couple of times to show the variance: You could have different macros for each biome, or, since muler constructions are resolved *after* Roll20 queries, you could have a query for the biome name: get.PlantMule.?{Biome|Forest|Desert|Grasslands|Marsh|Mountain}.[[1d100]].value/get If you wanted to run that as a rollable table and then roll using your die-roll, you would set up the rollable table with appropriate weights to each entry (10 for None, 10 for Plant 1, 20 for Plant 2, etc.). You'd also make sure that you create the table items in order, since they will be assigned value ranges based on their weight in order (so if the first item had a weight of ten, it would get the range of 1-10, the next item would start at 11 and have a range equivalent to its weight, etc.). The muler formation to roll against a rollable table (where the table is named ForestPlants) is: get.table.ForestPlants.[[1d100]].value/get ...and can be used in a template just as above. Both of these examples use ZeroFrame and Muler
1682179935
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
RainbowEncoder said: There is a new suggestion (still struggling for votes) that would let you use rollable tables with actual rolls:  Rollable tables with modifier/advantage/as lookup . This suggestion would give significantly more roll control for tables and if that interests you considering adding your voice and vote to it. My name is keithcurtis, and I endorse this suggestion. Seriously, this would be a literal "game changer" for macro functionality and automation.
Where do I vote for it ? 
So is there no way for a macro to be like "If roll 1 you get this" Kinda thing? Only through API?
The Keeper said: Where do I vote for it ?  In the suggestion thread Rollable tables with modifier/advantage/as lookup .  At the top just under the thread title is a triangle next to it's score. Click the triangle to vote and it should change colour. Mr. NumNums said: So is there no way for a macro to be like "If roll 1 you get this" Kinda thing? Only through API? Macros in general don't have if-then functionality. Depending on the exact details you may be able to do what you want using something from the Tips & Tricks thread. However were the suggestion implemented it would streamline some of those tricks.
1682230720
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Mr. NumNums said: So is there no way for a macro to be like "If roll 1 you get this" Kinda thing? Only through API? Macros are really very glorified dice roll printers, not a programming language. They don't possess logic or branching, and have only the most rudimentary storing of variables.
1682238320
GiGs
Pro
Sheet Author
API Scripter
Mr. NumNums said: So is there no way for a macro to be like "If roll 1 you get this" Kinda thing? Only through API? Correct. Dice rolls do not support any conditional values or lookups.
1682270356

Edited 1682270875
If using the D&D 5E by Roll20 sheet, another option for conditional output would be to use the mancerroll template.  It's limited to 20 entries which are normally equally weighted.  But you can use something like 3d6 for the roll if you want a bell curve with items in the middle of the list to be more likely to be displayed. &{template:mancerroll} {{title=Forrest}} {{c1=[[1d10]]}} {{option1=Nothing}} {{option2=Plant 1}} {{option3=Plant 2}} {{option4=Plant 3}} {{option5=Plant 4}} {{option6=Plant 5}} {{option7=Plant 6}} {{option8=Plant 7}} {{option9=Plant 8}} {{option10=Plant 9}}
1682511555

Edited 1682511569
Arc
Pro
Wow, thank you all for the suggestions! I'll definitely be voting for this! RainbowEncoder said: One thing to note is that only the ScriptCards answer can also show the d100 result since Rollable tables don't take in numbers. There is a new suggestion (still struggling for votes) that would let you use rollable tables with actual rolls:  Rollable tables with modifier/advantage/as lookup . This suggestion would give significantly more roll control for tables and if that interests you considering adding your voice and vote to it.
1682513017

Edited 1682513051
Arc
Pro
This is brilliant, I'll use this. Thank you so much! David M. said: