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

Sharing a macro with players when it accesses their character sheet

Hello all, New to DMing, and adding some macros to make things easier for my players. I came across a macro to roll Hit Dice during a long rest, but I feel like I'm missing the best way to share it with all the players. I can place it on each individual character sheet in the 'Attributes and Abilities' tab, but that means any edits/updates will need to be repeated for each player. I can put it in the Collection pane and make it visible to the players, but it seems whether it's a Token Action or on the macro bar it errors out (wrong context to retrieve the character sheet attributes I'm guessing). I tried creating a new character named "Shared Macros" and gave all players access, but this tries to get the attributes of the Shared Macros character and not the player using it. Here is the macro I cribbed from Reddit: @{wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=?{How Many|0}(D@{hitdie_final}+[[@{constitution_mod}[CON]]])}} {{r1=[[?{How Many}d@{hitdie_final}+[[?{How Many}*@{constitution_mod}]][CON]]]}} {{normal=1}} @{charname_output} To be clear, the macro functions fine, but I'm not able to share it except in the case of #1 above, which feels wrong. Someone has likely solved this already (or can definitively tell me "can't do that"). Any helpful pointers or advice appreciated, M
1591244608

Edited 1591278826
GiGs
Pro
Sheet Author
API Scripter
Macros that contain attributes require special consideration. Since every character in a campaign has the same attributes, when you run a macro, you need to tell roll20 which character to take the attributes from. There are four forms that command can take: @{hitdie_final} @{CHARACTERNAME|hitdie_final} @{selected|hitdie_final} @{target|hitdie_final} The first one above can only be used in abilities on individual character sheets (your point 1). Because it is on a character sheet, roll20 knows it is attached to that character sheet and uses that characters values. When you use it anywhere else (collections pane, a shared macro sheet), you need to supply the character that will use it. Option 2 above requires you to hardcode it with a specific character name. (Replace CHARACTERNAME with the actual character name.) This is impractical if you want every player to be able to use it. Option 3 requires you to select a token before running the macro, and it will use the attributes of the character attached to that token. Option 4 will prompt you to select a token, and then will use the linked character#s attributes. The Solution So the simplest solution to your problem is to add selected|  to the attributes in your macro (both constitution_mods and hitdie_final), and make the macro a Token action. (When you create a macro, there's a tickbox to mark it as a Token action). Token Actions appear at the top left of the screen when you select a token. So, when the player selected their token, they'll have a visible button to launch the macro. Selected requires a token be selected, and will fail if no token is selected. Making the macro a token action ensures players cant use the macro without first selecting the token, so it's the perfect way to handle it.
1591245984
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Super duper seconding of option 3. It centralizes the code and makes it foolproof to run. If you do want to keep everything in a Shared Macro sheet (to make it easier to export to other games, for instance), you can write the ability in the sheet and call it with a universal token macro in the collections tab: %{Shared Macros|Hit-Dice-Macro}
1591252569

Edited 1591252736
Oosh
Sheet Author
API Scripter
I've switched to a slightly different Hit Dice macro. Since 5e lets you roll them one at a time, and you generally don't want to waste them, I use this to roll them one at a time: @{selected|wtype}&{template:simple} {{rname=[ROLL AGAIN] (~Macros|HitDice) }} {{mod=D@{selected|hitdieroll}+[[@{selected|constitution_mod}[CON]]]}} {{r1=[[1d@{selected|hitdieroll}+[[@{selected|constitution_mod}]][CON]]]}} {{normal=1}} {{charname=@{selected|character_name} - **HIT DICE**}} Obviously edit the bold bit to suit your macro mule / macro name. It has a reroll button in the text so you decide one by one if you need any more, rather than deciding up front how many to spend and wasting them. Also outputs the character name regardless of sheet setting in case multiple people are rolling at once (pretty common). Because of the small text the link is in, it looks WAAAAAYYY better with Keith's absolutely brilliant inline link style fix . Regardless of whether you like the hit dice macro I highly recommend some Stylus fixes!
You guys are super awesome, very much appreciate the explanations and information. I'll move this in tonight! M
Well, I'm crawling back a bit embarrassed. I believed the instructions to be clear, but I can't get the macro to work, inserting the selected| addition to the macro fails. I tried with just the 'hitdie_final' and 'constitution_mod' attributes: @{wtype}&{template:simple} {{rname=^{hit-dice-u}}} {{mod=?{How Many|0}(D@{selected|hitdie_final}+[[@{selected|constitution_mod}[CON]]])}} {{r1=[[?{How Many}d@{selected|hitdie_final}+[[?{How Many}*@{selected|constitution_mod}]][CON]]]}} {{normal=1}} @{charname_output} and then added it to all of them which seemed they would possibly work. @{wtype}&{template:simple} {{rname=^{selected|hit-dice-u}}} {{mod=?{How Many|0}(D@{selected|hitdie_final}+[[@{selected|constitution_mod}[CON]]])}} {{r1=[[?{How Many}d@{selected|hitdie_final}+[[?{How Many}*@{selected|constitution_mod}]][CON]]]}} {{normal=1}} @{selected|charname_output} In neither case do they work, just give a "TypeError: Cannot read property 'substring' of undefined" Any other suggestions on what might be going on? Oosh - I plan to tackle your suggestion, but I want to understand and get this working before I jump another level up. 
1591425264

Edited 1591425320
Oosh
Sheet Author
API Scripter
The bottom one seems to be working for me: @{selected|wtype}&{template:simple}{{rname=^{hit-dice-u}}}{{mod=?{How Many|0}(D@{selected|hitdie_final}+[[@{selected|constitution_mod}[CON]]])}}{{r1=[[?{How Many}d@{selected|hitdie_final}+[[?{How Many}*@{selected|constitution_mod}]][CON]]]}}{{normal=1}}@{selected|charname_output} Couple of tiny tweaks - wtype needed the {selected}, and that ^{hit-dice-u} does not. No idea what's going on with top top one, it fails for me. But the r1 and mod fields are fine if I paste them into a new, identical template.
Argh, thank you for your patience. This community is amazing, but I'm finding myself frustrated by not having an easy time finding things explained and written out where I can find them Thank you again! M
Oosh - After getting the first macro to function and a better understanding of calling macros from chat and so forth, I tackled your iterative example. I had missed you were using a chat menu (still learning!), but recognize how brilliant that is for calling something easily again and again. I had a bit of a rough start because my mule was named 'Macros_Utils' and it took me a long time to figure out nothing was working because of the underscore character. But when I changed that, the heavens opened up. Thanks again for your patience and assistance. M