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

Having trouble with Macros for DND 1E session. Any help or explanation would be appreciated.

1697771663

Edited 1697782321
Hello All, Fairly new to roll20 and took some time trying to figure out how macros work but could only figure out the basics. First off... I would like to combine  &{template:attacks} {{color=@{color_option}}} {{name=@{character_name}}} {{subtag=@{weapon_name}}} {{attack1=[[1d20! + @{weapon_tohitbonus}[BON] + @{weapon_magicbonus}[MAG] + ?{To Hit Modifier?|0}[MOD] ]]}} {{damage1vsSM=[[@{weapon_damagesmallmedium} + @{weapon_attackdmgbonus}[BON] + @{weapon_magicbonus}[MAG] + ?{Damage Modifier?|0}[MOD] ]]}} {{damage1vsL=[[@{weapon_damagelarge} + @{weapon_attackdmgbonus}[BON] + @{weapon_magicbonus}[MAG] + ?{Damage Modifier?|0}[MOD] ]]}} {{WeaponNotes=@{weapon_notes}}} @{weapon_whisper_to_hit} with  &{template:default} {{name=Weapon)}} [[[[floor([[1d20+?cs=20]]/20)]]d4[Bleed]]] {{Hit $[[0]],Dmg[[1d8+?]]+$[[2]] Bleed}} Essentially using the first source code to be able to do an additional damage roll of 1d4 on an attack roll of 20. Secondly. This is my basic initiative roll that transfers to our Roll Table. [[d10+6 &{tracker}]] If I rolled a 2 on my d10, I would like the output to read 8,15.  Basically ->  [[d10+6,   d10+6roll+7  &{tracker}]] appearing in tracker as d10+6, d10roll+6+7  Only more complicated to make it work. Thank you for your help.
1697823286
timmaugh
Forum Champion
API Scripter
Hi, Ariana... There are a couple of ways you could mean to "combine" those templates. Do you want a situation where they would both run (solved by simply putting them in the same ability macro or collections tab macro with the second one on a new line)? Or do you want to  combine them in terms of getting them into the same template, so you would want the information that is in the second template to be displayed in the first template as part of that output? Or do you want to substitute the roll and output of the second template in place of part of the first template... and if so, which part (i.e., subbing in the roll and result instead of the right side of the attack1 template part)? As to your second question, I don't see a way to do that short of scripts. Someone else can perhaps show a solution that will work, but for now I can say that I can reproduce that number via metascript math, and that you should then be able to use another script like AddCustomTurn to get that value into the Turn Tracker. The caveat is that I'm using a decimal (which might be a regional thing), because the Tracker will only take numbers.
Hi,  Sorry for the confusion, Ultimately, I want to be able to use the first code on my 1e DND Character Sheet Weapon roll, but when I roll a 20 specifically on the "hit/attack" (1d20!) I want it to register as a "Crit" and apply an additional damage roll of 1d4 that is unaffected by the modifiers and has its own box, if that makes sense. The second code I posted was what worked on its own, but I would like the script to be able to pull information from my character sheet and not have to be manually entered. Thank you! I will try to figure out how to implement that meta script in a custom turn! All help is appreciated :)
Welcome to the fun, and often frustrating, world of macros.  The big problem with them is that they're basically linear text-substitution added onto the chat log's dice-rolling function, not a programming language.  What that specifically means is that you can't branch, such as doing If A is true do B else do C, etc. (you may already know that, but I prefer to be clear). But there are a number of complex ways to get things to almost do that using math (in essence you compute two values and arrange to multiply one of them by 0 and one by 1 to "pick" the correct one). That has a lot of limitations and can be very hard to figure out (I usually just google until I find someone else solving the problem and use their macro).  Check out the following pages if you haven't already: Dice Rolling Reference Complete Guide to Macros and Rolls Reusing Rolls A script (API script, newly renamed Mod) is a javascript (program) that can do a lot more, but it's a PRO feature (it's also hair-pullingly hard if you're not a web programmer), although there are a lot of pre-written ones availabile to solve common problems. But you can get most of what I think you want with macros, although as you'll see in the example below, there are limits to that. For your "roll an extra d4 on a 20", it looks like you are basing this on the example in this post using the floor function . The example given in post rolls an extra d8 on a crit in the first attack roll, so changing that to 1d4 is simple. And from there, it's "just" a matter of how you add modifiers, which is where the trouble sets in. Here's an example of how those elements work: &{template:default} ?{Weapon|Battleaxe 1H,1d8 [Battleaxe 1H]|Battleaxe 2H,1d10 [Battleaxe 2H]} ?{mods|0|1|2|3|4|5} {{name=Weapon)}} {{formula [[ [[floor([[1d20+?cs=20]]/20)]]d4]] }} {{zero $[[0]]}}  {{one $[[1]]}} {{two $[[2]]}} {{three $[[3]]}}  {{Hit $[[0]] + ?{mods}, Dmg [[?{Weapon}+?{mods}]] + $[[2]] Bleed}} I've broken the elements out into separate lines, so you can see how the parts work (I'm using a simple query for weapon damage and mods, rather than an ability reference, because such references are sheet-specific). But note the problem, the last line summary of the roll to hit shows the dice roll and mods to it as separate numbers.  There's no way I know of to add a modifer to a referenced roll without breaking it (a limitation of the lineline rolls functionality accordding to the Reusing Rolls page noted above). A simple version takes the extra lines away, and calculates the crit dice number (along with the roll) outside of the template (no curly braces) so it doesn't show separately: &{template:default} ?{Weapon|Battleaxe 1H,1d8 [Battleaxe 1H]|Battleaxe 2H,1d10 [Battleaxe 2H]} ?{mods|0|1|2|3|4|5} {{name=Weapon)}}  [[ [[floor([[1d20+?cs=20]]/20)]]d4]]    {{Hit $[[0]] + ?{mods}, Dmg [[?{Weapon}+?{mods}]] + $[[2]] Bleed}} But that's the best I can get. I don't follow your initiative question. Where does the 7 come from?  In any case, I don't think there's a way to post a second number to initiative.
Hi Ken, Thank you! That answers a lot of my questions! For the initiative, this is the breakdown which probably would make it easier. [[d10-(Dex Modifier)-(WeaponFamiliarity)+7 &{tracker}]]    The d10 being our base initiative die, subtracted from my 1 Dex modifier, with no weapon familiarity makes me end up with my d10+6 for my base initiative roll. Now for "Where does the 7 come from?" When we are using bows in our campaign, we get an additional attack 7 segments later in our turn order and we normally just edit the turn order after it does the initial roll to show our initialroll.initialroll+7 Therefor our gm knows we have a turn on that segment and 7 segments later. If I rolled a 4 on my d10 it would be 10 on the turn order, and we would edit it to 10.17
Doing this cleanly is something you can only do with a script.  There's a discussion from a couple of years ago about it here . While it's possible to reference an existing token's entry on the tracker and perform math on it, there's no way I can see to reference that when you add another entry for a second token, probably because of the way macros get evaluated (at least, everything I tried failed). You can sort-of hack this to work though. Note that this approach adds it numerically 7 after the first, there's no way to reference the order itself and add something N players later. To do so, post your initiative as normal (from your sheet or using a macro). For example purposes, let's assume you have a character named Thud the Barbarian with a token named Thud. Here's an example initiative macro for a 5E sheet, the @{selected|initiative_bonus} would need to be replaced with whatever your sheet/system uses for standard initiative modifier(s). This is a macro I found somewhere years ago. Oddly, I can't find where @{selected|initiative_style} is documented, it may also be specific to the 5E sheet (its the part that does the d20 roll, so you can just replace it with 1d20 or whatever you need). &{template:simple} {{rname=Initiative }} {{mod=@{selected|initiative_bonus}}} {{r1=[[ @{selected|initiative_style} + @{selected|initiative_bonus} &{tracker} ]] }}  {{normal=1}} {{charname=@{selected|token_name}  }} Note that you have to select your token (Thud) before calling the macro (so make it a Token Action macro) and the initiative is posted as "Thud" followed by whatever number is rolled. Have the DM add  a dummy token on the tabletop for each player (you could use a graphic of a bow), and name them something like "Thud's Arrows" for yours. This could also be done with a dummy sheet for each player with a named token (like a bow) that they could drag to the tabletop, to make life simpler for the DM. Next select "Thud's Arrows" on the tabletop, and call a macro like this one: &{template:simple}  {{rname=Arrow Initiative }} {{r1=[[ [[?{Old Init} - 7 ]] &{tracker}]] }} {{normal=1}} {{charname=@{selected|token_name}  }} This will pop up a box asking you to enter a number for "Old init", where you would type in the initial value added for Thud, it would then subtract 7 and post that number for Thud's Arrows. It would be nice if, instead of prompting the caller, it could use targeting to get the initiative for the Thud token and then do the math on that, but I can't see any way to make that work.