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 .
×

Macro Noob looking for Help :)

Hello all you lovely People :)  Since my brain goes blank as soon as something that even resembles programing comes near it, I need the help of you all, cause youre way smarter than me :D  I'm using the "D&D 5E by roll20" Character sheet and looking for a way to make the following thing happen for my players:  I'd like to give them a Button that if pressed does a Nature Check against a DC of 15. If it is a success it should give them a Text of plants they found.  For this i have different rollable tables that all come into play - first one to determine the Number of Plants, and then one that determines the Plant, but that one would need to prompt me to select the biome first.  I'm sorry if my English is a bit bad since it is not my best skill :(.  well maybe someone is able to help :) 
I am a programmer, and roll20's macros make my head hurt. I won't call myself an expert, but I've had to write a few for my game. The below is based on things I found in the wiki and a number of separate posts in the forums over a couple of years of playing with macros. I don't think you can select text from a list using a roll that's conditional on success, but there are some tricks to make one roll conditional on another using math, so it might be possible.  That's beyond my level.  You can, however, use two separate macros: one to make the check, and if it works, a second to describe what they found. Here's a a basic nature roll with a dc check: &{template:default}{{name=@{selected|character_name} Nature check}}{{ Checking: [[ {1d20cf<0cs>21+@{selected|nature_bonus} [Nature Modifier]}>[[?{DC} ]] ]] 1 is Success }} This is done as a token macro, and the player must select their token before rolling so it can look up values on the associated sheet. This is a fairly basic check, and doesn't take global modifiers into account.  The player needs to input the DC when prompted, and it will display either 0 or 1 in the yellow box, with 1 meaning that the roll was greater than or equal to the DC (roll20 uses ">" to mean "greater then or equal"). And here's a roll to display one entry from from a list (you can have up to 20 results, with a d20 in c1, and option1-option20): &{template:mancerroll} {{title=Plant Found}} {{c1=[[1d4]]}} {{option1=Apple}} {{option2=Pear}} {{option3=Orange}} {{option4=Avocado}}
1674412934

Edited 1674413020
GiGs
Pro
Sheet Author
API Scripter
Ken is correct there's no way to directly display text based on a condition. If your table for text output doesnt have a modifier*, I'd put the entries in a rollable table, and have button to roll that table. So you have a macro the shows the nature roll, and in the same macro have a button to click to launch a second macro which is the table roll. * Rollable tables dont work with modifiers, for some bizarre reason. Also, since you're Pro, you could have the roll and table roll in a single macro do this with a script, like ScriptCards. If you are iwlling to use a script, it is probably worthwhile to ask in that script's thread.
Thank you both so much, this helps me tremendously allready! ❤️
1674486445
timmaugh
Roll20 Production Team
API Scripter
GiGs said: * Rollable tables dont work with modifiers, for some bizarre reason. The current beta version of Muler lets you roll against a rollable table with modifiers. =D I have a request for an added feature that I'm going to incorporate and then I'll submit it to the one-click. That said, I'm not sure there's a need for modifiers in this case (at least not at my current understanding of the use case). But if there's a need for conditionals, you can get that with APILogic. Basically you could make the check against the appropriate attribute, and include the information if successful, or include text that explains that the roll failed if it was unsuccessful. All of that would be in one message. You could even use different roll templates depending on the outcome. To do it right, I'd use a few metascripts: APILogic: for conditionals Muler: to store the plant information for each biome ZeroFrame: to output the template to chat I can provide an example setup if you're interested.
That sounds great i would love to see it.  Not sure what would be needed - the DC for the Nature check wouldn't vary it would always be the same difficulty  I then have multiple Rollable Tables for different Climate and Terrain zones like dessert and forest, that i would like to choose.  The next Random part is then just a roll on another Table that decides on the amount gathered.  so in my head it is: Nature check - select Terrain - Roll Plant - Roll amount.  I dont know if that helps to clarify.  For now i will try Ken S. solution since it is allready better than what i do currently :D
1674585949
timmaugh
Roll20 Production Team
API Scripter
OK, some assumptions I'm making: ...the nature check against a DC15 is roughly what Ken proposed (adding the nature_bonus attribute of a selected character) ...after selecting the terrain/biome, there might be a number of plants found there. Currently I've hard-coded that to be 1d4, but that could be changed and/or diversified (so that every biome had more/less plants, or so that the calculation took into account the quality of the initial check against DC15) ...that each plant might have a rarity associated with it, so that if it is found you might tend to find more/less of it ...that the player would be making this roll if you told them what biome to roll (this is easily changed; see the end of this message for how) My Setup Given those assumptions, here is my setup: 0) REQUIRED SCRIPTS : ZeroFrame, Muler 2.0 , MathOps, Fetch, and APILogic (all available from the 1-click, except the linked Muler version, which is in beta and about to be released to the 1-click) 1) A character named "TableMule" (control rights should be granted to anyone who wants to use this solution) 2) On TableMule, create an ability for each biome. I created one for "DessiduousBiome" and one for "ConiferousBiome" 3) In each biome ability, create line entries for each plant that might be found there. The line entries should start with a number, with the first line starting at 1 and subsequent lines counting up from there. That number is what you will "roll" on dice, so then we set it equal to what you get (ie, the kind of plant) if you roll that value. 3a) I set up my lines to be the plant and then another "=" and then a die roll. I'm going to use the default roll template, so the plant name will be the left side of a line of output, and the roll will be the right side. The roll, in my imagined setup, is the amount of the plant that the character might find if that plant is rolled/returned from the biome. 3b) The last entry in each biome should be called max, and it should be set equal to a roll that matches the maximum value represented. Since I'll have 3 items in each biome, I'd use [[1d3]]. Here are my two biome abilities: Your rolls don't have to include the cs/cf trick, I was just trying to keep the look of the final presentation consistent -- no critical or fumble formatting. Here is my biomes as text, if you just wanted to quickly replicate my setup for testing in your game: DessiduousBiome 1=Loo Runner=[[1d8cf<0cs>9]] 2=Potentis Wort=[[1d4cf<0cs>5]] 3=Gillyweed=[[1d6cf<0cs>7]] max=[[1d3]] ConiferousBiome 1=Heckleberry=[[1d8cf<0cs>9]] 2=Sprongroot=[[1d4cf<0cs>5 + 1]] 3=Tongue Slapper=[[2d4cf<0cs>5]] max=[[1d3]] 4) Create another ability on TableMule called NatureCheckRows . This one will take 3 entries, exactly like this: needed=3 current=4 reportline={\&if get.NatureCheckRows.needed >= get.NatureCheckRows.current/get}{{(get.NatureCheckRows.current/get) get\\\\.TableMule.biomevar.get\\.TableMule.biomevar.max/get\\\\.value/\\\\get}} set\.NatureCheckRows.current = {\&math get.NatureCheckRows.current + 1}/set get.NatureCheckRows.reportline/get{\&end}{&0 get apil math set} 5) Create one more ability on TableMule. You can call it what you want; I called mine NatureCheck . Here is the text of that ability: !/w "@(speaker.player_name)"  &{template:default} {&define ([checkvar][[[[1d20]]+@{selected|nature_bonus}]].value) ([biomevar]?{Biome|Dessiduous,DessiduousBiome|Coniferous,ConiferousBiome}) ([plantsfound][[1d4]].value)} {{name=Nature Check (biomevar)}}{{Roll=$[[0]] + @{selected|nature_bonus}= $[[1]]}}{{Result={&if ([logiccheck]checkvar >= 15)}***Success!***{&else}***Fail!***{&end}}}{&if logiccheck}get\\.TableMule.NatureCheckRows.reportline/get {&else} {&end}{&simple}set\.TableMule.NatureCheckRows.needed = {&if logiccheck}plantsfound{&else}0{&end}/set set\.TableMule.NatureCheckRows.current = 1/set Example Output Using the above setup, I selected a token with the nature_bonus attribute, then I ran the NatureCheck ability. That check passed. If it fails, it would look more like: Also, there's no way to limit the available items so that you never get a duplicate. In one case, I got three returns of the same type of plant: Obviously, the more items you have in your list, the less likely you are to get a duplicate return. How You Expand This If you want to add more biomes (or not use the Dessiduous/Coniferous biomes), just create the ones you need as I talked about: 1=plant name=[[...roll for amt...]] 2=...etc. ... n=... max=[[1d n ]] Then you'll want to alter the roll query that is in the NatureCheck ability. Specifically, that query currently reads: ?{Biome|Dessiduous,DessiduousBiome|Coniferous,ConiferousBiome} Just add/remove the biomes you actually require, making sure that the second part of each entry (the part after the comma in each entry) matches the biome's ability's name (ie, "DessiduousBiome" is what I called the library of plants in the Dessiduous biome, so I used that name, exactly). How You Change This Changing Who Runs The Command If you want to run the command instead of your players but you still want to whisper the results to them just change the whisper target at the beginning of the NatureCheck command. Change it from "@(speaker.player_name)" to "@{selected.character_name}" Changing the Number of Plants Returned If you want to change the generation of the number of plants, look for the bit of the NatureCheck command that reads: ([plantsfound][[1d4]].value) Change that inline roll equation to be something else. I know you said you tend to check out when things turn "programming-ish", so I won't put a ton of details here... so if you can't get it to work with  your roll, or if you want to use some other component (like the margin of success vs DC15), post back and I'll help. Making a Plant More or Less Rare Right now each plant has an amount that could be found of it, but they each have an equal chance of being found in the first place. This is because every entry in the biome is setup to be a single number (ie, 1=Potentis Wort... ). You can alter the weights of individual items by giving each entry a range of values: 1-2=Option A 3=Option B 4-7=Option C >8=Option D In that setup, Option A has twice as much chance of occurring as Option B (happening on a 1 or a 2 for A, as opposed to just 3 for B), while Option C has 4x the chance of B and 2x the chance of A (happening on a 4, 5, 6, or 7). If you rolled a 1d8 to return from this table, Option D would only have a 1-in-8 chance of occurring, however, if you were to roll using something that involved the nature_bonus attribute of the selected character, you could put a finger on the scales: [[1d8 + @{selected|nature_bonus}]] (note this roll won't work as the value of the max entry for a biome for... well... for reasons that would make this long post a lot longer... but a version of that roll could be replicated using Fetch or MathOps.) That would effectively make it less likely that the character would find lower-numbered plants, and more likely that they would find higher-numbered plants, and could represent their skill helping them find more valueable/useful plants.