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

NPC Statblock Chat Menu for D&D 5e sheet — No API required!

1585542435

Edited 1620742487
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I have seen a lot of variations of requests for something like this come along with the influx of new users (Hi Everyone!) "How can I run a monster without opening the character sheet? I want its attacks on buttons." The following macro will whisper a  Chat Menu  to the GM containing the monster's basic statblock. Nearly everything it reports is a clickable button. No API is required for this—it runs on basic macro commands and the D&D 5th Edition by Roll20 sheet's built-in Abilities. I will show you how to install this macro (in only one spot!) and have it work for all NPCs in your game. Some restrictions and suggestions: The basic roll templates in the 5e sheet use the default Roll20 Big Pink Button. This is fine for a Chat Menu with a few commands, but it really makes the output huge and unwieldy. The opposite of what you want. Although in no way required, I strong advise anyone using this to install the Stylus extension for their browser and install the style below to modify the buttons into simple text links. (Full instructions are at the top of the linked thread. It's very simple.) Inline Links on OGL Roll Templates Because macros have no conditional logic, the macro has no idea how many actions are on the character sheet. I have written it for the top five actions, which should be good enough in most cases. If your create has more, they won't display, but a creature that complex likely should have it's sheet open and available (you can minimize any sheet by double-clicking its header). If it has fewer actions, the last few buttons will have garbage labels. Just ignore them. There are some excellent solutions for this using the API, but I want to present something usable by all users. This will only work for NPC sheets . PC sheets use different attributes and are complex enough that a free solution would not serve them as well. This does not handle spellcasting , again, because there is too much conditional logic involved. If you are running a spellcaster, keep the sheet open and minimized or open in a popped out window for reference. What does it look like? If you install the stylus extension above, it will look like this. Skills and Actions are clickable. If you click an attribute, it will make an attribute roll, if you click the word "save" after the attribute, it will make the corresponding saving throw. Similarly, it will roll skill checks and Actions. I have not included an initiative button. That should have its own token action button. I'll give that as a bonus at the bottom of this post. How do I install it? You'll want to install it so that is instantly usable by all tokens that are linked to an NPC character sheet. Create a new macro in your Collections tab and name it "Statblock" After you have pasted the code below and but before you have saved the macro click the button that says, "Show as Token Action?" It should look like the example below. Because you have saved this as a token action in your macros tab, it is instantly available to you, the DM, whenever you select a token that represents a character. You do not have to install it on every sheet. The button will even appear when you select a PC token, but remember, the code is designed for NPCs. You will get mostly garbage if you try to run this for a PC. By the way, don't click "In Bar" for this macro. It only has value as a  token  action and doesn't make sense to be in the macro quick bar at the bottom. Where is the code? Right here: /w gm &{template:npcaction}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type} **HP: **@{selected|bar1} / @{selected|hp|max} | ** AC: ** @{selected|npc_ac} | **Spd: ** @{selected|npc_speed} **Languages: **@{selected|npc_languages}  **Senses: **@{selected|npc_senses}  **Resists:: **@{selected|npc_resistances}  **Immune: **@{selected|npc_immunities}  **Cond. Immune: **@{selected|npc_condition_immunities}}}{{description=**Abilities** [**Str @{selected|strength}** *(@{selected|strength_mod})*](~selected|npc_str) | [save](~selected|npc_str_save) [**Dex @{selected|dexterity}** *(@{selected|dexterity_mod})*](~selected|npc_dec) | [save](~selected|npc_dex_save) [**Con @{selected|constitution}** *(@{selected|constitution_mod})*](~selected|npc_con) | [save](~selected|npc_con_save) [**Int @{selected|intelligence}** *(@{selected|intelligence_mod})*](~selected|npc_int) | [save](~selected|npc_int_save) [**Wis @{selected|wisdom}** *(@{selected|wisdom_mod})*](~selected|npc_wis) | [save](~selected|npc_wis_save) [**Cha @{selected|charisma}** *(@{selected|charisma_mod})*](~selected|npc_cha) | [save](~selected|npc_cha_save) **Skills** [Acrobatics](~selected|npc_Acrobatics) | [Animal Handling](~selected|npc_Animal_Handling) | [Arcana](~selected|npc_Arcana) | [Athletics](~selected|npc_Athletics|Deception](~selected|npc_Deception) | [History](~selected|npc_History) | [Insight](~selected|npc_Insight) | [Intimidation](~selected|npc_Intimidation) | [Investigation](~selected|npc_Investigation) | [Medicine](~selected|npc_Medicine) | [Nature](~selected|npc_Nature) | [Perception](~selected|npc_Perception) | [Performance](~selected|npc_Performance) | [Persuasion](~selected|npc_Persuasion) | [Religion](~selected|npc_Religion) | [Sleight of Hand](~selected|npc_Sleight_of_Hand) | [Stealth](~selected|npc_stealth) | [Survival](~selected|npc_survival) **Actions** [@{selected|repeating_npcaction_$0_name}](~selected|repeating_npcaction_$0_npc_action) [@{selected|repeating_npcaction_$1_name}](~selected|repeating_npcaction_$1_npc_action) [@{selected|repeating_npcaction_$2_name}](~selected|repeating_npcaction_$2_npc_action) [@{selected|repeating_npcaction_$3_name}](~selected|repeating_npcaction_$3_npc_action) [@{selected|repeating_npcaction_$4_name}](~selected|repeating_npcaction_$4_npc_action) }} &{noerror} Thanks to Alan for some proofreading, and a great suggestion (incorporated above.) Those last long lines are the ones that control the display of NPC actions. You can add or delete to your taste following the displayed pattern. Where is that Initiative Macro you promised? Right here. Install it the same way you installed the Statblock macro, as a universal token action. Because of the limitations of Roll20, this will only work on one selected token at a time. If you need to roll for a group with one click, that will require the API. Like the Statblock macro, this will only work on NPC tokens. %{selected|npc_init} If you want to make one for players to use as well, create a separate macro with the code below, and save it as you did the others, with one exception. In the permissions field of the macro, choose "All players". Everyone will have a token action they can use to roll initiative as long as they have their token selected. %{selected|initiative} Bonus bonus. Spellblock Macro (later in this thread). Jarren K has made an improved version: Universal NPC Statblock Abilities and Spells Chat Menus for D&D 5e sheet — No API or Stylus required!
1585542448
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
By the way, if you decide not to install the stylus extension linked in the top ppost, the macro will still work. It will just look like this. which is something no one wants:
1585544748
GiGs
Pro
Sheet Author
API Scripter
Very nice work!
1585545225
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I think you can guess where I re-purposed a lot of the code from... :)
So I have tons of questions and thoughts but I need to start playing with this first before I should ask questions.  As you have began to help me with my other problems as well. I have a list a mile long to get my campaign prepared that I was going to start in person now I need to on roll20 and I have barely ever used roll20 
Ok now that I have read this better this might be even better than what o was trying to do before with that video or I can try to tie them together.  So the interactive stat block is a whisper to the chats?  And if I click on the token the token will have a stat block macro? And where will the attacks be on the screen or in the chat? 
1585696809
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yes on all counts. :) They will be sent to chat according to whatever the whisper settings are for that sheet.
If I use the combat API does the init macro still work or is it needed? 
1585780424
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
If you are talking about Combat Master, it gives you the option.
So I Entered it and am getting this is this because my monster only has one attack?
1585807571
vÍnce
Pro
Sheet Author
This might help  [5e OGL] Suppressing Errors Messages "&{noerror} " workaround
1585829526

Edited 1585829730
What about traits?  I can figure out how to get the trait name in there, but there are times that I might need the description as well.  I can't figure out how to get both.  And, some creatures may have more than one trait. Thx
1585848752

Edited 1617770604
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I was intentionally trying to keep it short and minimize the number of garbage lines where no such attribute exists, but to add traits, add lines in this pattern: [@{selected|repeating_npctrait_$0_name}](~selected|repeating_npctrait_$0_npc_roll_output) [@{selected|repeating_npctrait_$1_name}](~selected|repeating_npctrait_$1_npc_roll_output) ... Aside: note that this action name is unlike any other action name on the sheet. The official sheet is often harder than it needs to be. This has been fixed on a subsequent update of the sheet. The code above is corrected to match.
This is amazing exactly what i am looking for 
This is amazing also got the style thing to work.  Thanks SOOOOO much this is a huge time saver for a DM.  Thanks Keith !!!!!
Okay so I love this and your work. I am able to get rid of quite a few token macro because of this one. I added a few things to it and was trying to tie it all together. But I have a small issue. I can't quite get the last bit I added to work. I have buttons at the end of this that are for traits, actions, and reactions. They call other macros That I have so that i can save some space. However they aren't working. I was hoping you could take a look at this because I am baffled on why it wont work. From what I know this should work. I have used this method in the past.    This is the error I get when I try to use any of the buttons at the end. (Traits, Actions, and Reactions) All others work. Here is my macro. /w gm &{template:npcaction}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type} **HP:**@{selected|bar1} / @{selected|hp|max} | **AC:** @{selected|npc_ac} | **Spd:** @{selected|npc_speed} **Challenge:** @{selected|npc_challenge} | **XP:** @{selected|npc_xp} **Languages:** @{selected|npc_languages} **Senses:** @{selected|npc_senses} **Resists:** @{selected|npc_resistances} **Immune:** @{selected|npc_immunities} **Cond. Immune:** @{selected|npc_condition_immunities}}}{{description=**Abilities** [**Str @{selected|strength}** *(@{selected|strength_mod})*](~selected|npc_str) [save](~selected|npc_str_save) | [**Dex @{selected|dexterity}** *(@{selected|dexterity_mod})*](~selected|npc_dex) [save](~selected|npc_dex_save) [**Con @{selected|constitution}** *(@{selected|constitution_mod})*](~selected|npc_con) [save](~selected|npc_con_save) | [**Int @{selected|intelligence}** *(@{selected|intelligence_mod})*](~selected|npc_int) [save](~selected|npc_int_save) [**Wis @{selected|wisdom}** *(@{selected|wisdom_mod})*](~selected|npc_wis) [save](~selected|npc_wis_save) | [**Cha @{selected|charisma}** *(@{selected|charisma_mod})*](~selected|npc_cha) [save](~selected|npc_cha_save) **Skills** [Acrobatics](~selected|npc_Acrobatics) | [Animal Handling](~selected|npc_Animal_Handling) | [Arcana](~selected|npc_Arcana) | [Athletics](~selected|npc_Athletics) | [Deception](~selected|npc_Deception) | [History](~selected|npc_History) | [Insight](~selected|npc_Insight) | [Intimidation](~selected|npc_Intimidation) | [Investigation](~selected|npc_Investigation) | [Medicine](~selected|npc_Medicine) | [Nature](~selected|npc_Nature) | [Perception](~selected|npc_Perception) | [Performance](~selected|npc_Performance) | [Persuasion](~selected|npc_Persuasion) | [Religion](~selected|npc_Religion) | [Sleight of Hand](~selected|npc_Sleight_of_Hand) | [Stealth](~selected|npc_stealth) | [Survival](~selected|npc_survival) **Other Statistics** [Traits](~NPCTraits) | [Actions](~NPCActions) | [Reactions](~NPCReactions)}} &{noerror} And the other macro is here /w gm &{template:npcaction}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type} **HP: **@{selected|bar1} / @{selected|hp|max} | ** AC: ** @{selected|npc_ac} | **Spd: ** @{selected|npc_speed}}}{{description=**Traits** [@{selected|repeating_npctrait_$0_name}](~selected|repeating_npctrait_$0_-npc_roll_output) [@{selected|repeating_npctrait_$1_name}](~selected|repeating_npctrait_$1_-npc_roll_output) [@{selected|repeating_npctrait_$2_name}](~selected|repeating_npctrait_$2_-npc_roll_output) [@{selected|repeating_npctrait_$3_name}](~selected|repeating_npctrait_$3_-npc_roll_output) [@{selected|repeating_npctrait_$4_name}](~selected|repeating_npctrait_$4_-npc_roll_output)}} &{noerror} It all works on it's own I just can't call the traits, actions, or reactions from the main macro.
1589590440

Edited 1589590906
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
[Traits](~NPCTraits) | [Actions](~NPCActions) | [Reactions](~NPCReactions) Is expecting to find Abilities on a character sheet. You appear to have written them as Macros on the Collections tab. The correct way to call them would be: [Traits](!
#NPCTraits) | [Actions](!
#NPCActions) | [Reactions](!
#NPCReactions) Or you could write them into a  Macro Character Sheet  called, say, "Macros", in which case the code would be: [Traits](~Macros|NPCTraits) | [Actions](~Macros|NPCActions) | [Reactions](~Macros|NPCReactions) For information about why the syntax is this way, and to see other cases, see:  Chat Menus
That was it. I forgot about that. Thanks for that.
1589767292
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Spellblock Macro Here is a different menu. This one calls all spells. Again, because  macros have no conditional logic, the macro has no idea how many spells are on the character sheet. I have written it for the to cover most spellcasting NPCs, using the lich and the archmage as targets for maximum spells per level. You may want to adjust this into a High Level Macro (as written) and a Low level macro (cut off at level 5 or so). You can also adjust the number of spells up or down per level, to taste. The pattern should be easy enough to decipher. If the caster hasn't enough spells to fill the number of buttons, you will get garbage buttons, but this is unavoidable. See the top post for how to avoid Big Pink Buttons. Sample output: Spellblock code: /w gm &{template:npcaction}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type}}}{{description=**Caster Level: @{selected|caster_level}** **Spell Save DC: @{selected|spell_save_dc}** **Spellcasteing Ability Mod: [[@{selected|spellcasting_ability}@{selected|pb}]]** **Cantrips** [@{selected|repeating_spell-cantrip_$0_spellname}](~selected|repeating_spell-cantrip_$0_spell) [@{selected|repeating_spell-cantrip_$1_spellname}](~selected|repeating_spell-cantrip_$1_spell) [@{selected|repeating_spell-cantrip_$2_spellname}](~selected|repeating_spell-cantrip_$2_spell) [@{selected|repeating_spell-cantrip_$3_spellname}](~selected|repeating_spell-cantrip_$3_spell) [@{selected|repeating_spell-cantrip_$4_spellname}](~selected|repeating_spell-cantrip_$4_spell) **Level 1** [@{selected|repeating_spell-1_$0_spellname}](~selected|repeating_spell-1_$0_spell) [@{selected|repeating_spell-1_$1_spellname}](~selected|repeating_spell-1_$1_spell) [@{selected|repeating_spell-1_$2_spellname}](~selected|repeating_spell-1_$2_spell) [@{selected|repeating_spell-1_$3_spellname}](~selected|repeating_spell-1_$3_spell) [@{selected|repeating_spell-1_$4_spellname}](~selected|repeating_spell-1_$4_spell) **Level 2** [@{selected|repeating_spell-2_$0_spellname}](~selected|repeating_spell-2_$0_spell) [@{selected|repeating_spell-2_$1_spellname}](~selected|repeating_spell-2_$1_spell) [@{selected|repeating_spell-2_$2_spellname}](~selected|repeating_spell-2_$2_spell) [@{selected|repeating_spell-2_$3_spellname}](~selected|repeating_spell-2_$3_spell) [@{selected|repeating_spell-2_$4_spellname}](~selected|repeating_spell-2_$4_spell) **Level 3** [@{selected|repeating_spell-3_$0_spellname}](~selected|repeating_spell-3_$0_spell) [@{selected|repeating_spell-3_$1_spellname}](~selected|repeating_spell-3_$1_spell) [@{selected|repeating_spell-3_$2_spellname}](~selected|repeating_spell-3_$2_spell) [@{selected|repeating_spell-3_$3_spellname}](~selected|repeating_spell-3_$3_spell) **Level 4** [@{selected|repeating_spell-4_$0_spellname}](~selected|repeating_spell-4_$0_spell) [@{selected|repeating_spell-4_$1_spellname}](~selected|repeating_spell-4_$1_spell) [@{selected|repeating_spell-4_$2_spellname}](~selected|repeating_spell-4_$2_spell) **Level 5** [@{selected|repeating_spell-5_$0_spellname}](~selected|repeating_spell-5_$0_spell) [@{selected|repeating_spell-5_$1_spellname}](~selected|repeating_spell-5_$1_spell) [@{selected|repeating_spell-5_$2_spellname}](~selected|repeating_spell-5_$2_spell) **Level 6** [@{selected|repeating_spell-6_$0_spellname}](~selected|repeating_spell-6_$0_spell) [@{selected|repeating_spell-6_$1_spellname}](~selected|repeating_spell-6_$1_spell) **Level 7** [@{selected|repeating_spell-7_$0_spellname}](~selected|repeating_spell-7_$0_spell) [@{selected|repeating_spell-7_$1_spellname}](~selected|repeating_spell-7_$1_spell) **Level 8** [@{selected|repeating_spell-8_$0_spellname}](~selected|repeating_spell-8_$0_spell) [@{selected|repeating_spell-8_$1_spellname}](~selected|repeating_spell-8_$1_spell) **Level 9** [@{selected|repeating_spell-9_$0_spellname}](~selected|repeating_spell-9_$0_spell) [@{selected|repeating_spell-9_$1_spellname}](~selected|repeating_spell-9_$1_spell) }} &{noerror}
1589775701

Edited 1589775993
Oosh
Sheet Author
API Scripter
Extremely minor addition to the above, using Keith's Stylus improvement to get rid of big pink buttons and then adding blank entries (click the + button, put a single space in the title field, then click the close cog) will give you some lovely clean blank lines in the output. Only really relevant where you have a reasonable limit on the monsters, so you can make sure they all have the same number of actions/reactions/spells - either populated or added as blanks. Goblin with 2 actions, 4 blank actions, macro calls all 6: Obviously the same deal for any other repeating fields. I know absolutely nothing about CSS, I'm going to assume that it's not possible to say... change anything that gets sent to the chat log and has the string "|repeating_" in it to white text?
1589780706
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
As far as I can tell, CSS has no conditionals other than "what browser are you using?". If someone does know, though, that would be great.
I created this to call for a martial NPC that has traits, actions, and reactions that might be forgotten in the heat of combat. By calling this macro you are shown all your options and can help to remind you that there is more to your npc than simple hit and wait. You can expand it just like above too. Here is the code /w gm &{template:npcaction}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type} }}{{description=**HP: **@{selected|bar1} / @{selected|hp|max} | ** AC: ** @{selected|npc_ac} | **Spd: ** @{selected|npc_speed} _____________________________ **Traits** [@{selected|repeating_npctrait_$0_name}](~selected|repeating_npctrait_$0_-npc_roll_output) [@{selected|repeating_npctrait_$1_name}](~selected|repeating_npctrait_$1_-npc_roll_output) **Actions** [@{selected|repeating_npcaction_$0_name}](~selected|repeating_npcaction_$0_npc_action) [@{selected|repeating_npcaction_$1_name}](~selected|repeating_npcaction_$1_npc_action) [@{selected|repeating_npcaction_$2_name}](~selected|repeating_npcaction_$2_npc_action) [@{selected|repeating_npcaction_$3_name}](~selected|repeating_npcaction_$3_npc_action) [@{selected|repeating_npcaction_$4_name}](~selected|repeating_npcaction_$4_npc_action) [@{selected|repeating_npcaction_$5_name}](~selected|repeating_npcaction_$5_npc_action) [@{selected|repeating_npcaction_$6_name}](~selected|repeating_npcaction_$6_npc_action) [@{selected|repeating_npcaction_$7_name}](~selected|repeating_npcaction_$7_npc_action) **Reactions** [@{selected|repeating_npcreaction_$0_name}](~selected|repeating_npcreaction_$0_-npc_roll_output) [@{selected|repeating_npcreaction_$1_name}](~selected|repeating_npcreaction_$1_-npc_roll_output)}}&{noerror} I would have never figured this out without this post actually. I've been using thousands of token actions to do this and I finally had enough and this post was one of the first things that popped up. Thanks @keithcurtis. But now I can't stop, I keep seeing better ways of doing things all from this simple method. I even implimented it for some of my PC's. I'm teaching it to some of my friends running their own game too. I really like your work and the way you engage the community.
Wow, I love this! Would this be possible: A seperate Token Action Macro that whispers to the Dungeon Master all the Feats and Reactions. I have added the Feats to the list but when I click it, it won't whisper it but just broadcasts it.
1589835272
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Post your code. It should all be contained within one roll template, no breaks between fields, and be preceded by "/w gm "
1589835318
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ah, do you mean when you click the feat or reaction it broadcasts it? That's the setting of the individual sheet.
keithcurtis said: Ah, do you mean when you click the feat or reaction it broadcasts it? That's the setting of the individual sheet. Yes, when you click it. 
1589837374
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Open the sheet, click the gear and change the settings to always whisper. If you want all characters to whisper by default: Always Whisper Go to the Campaign Settings Page Choose "Always Whisper Rolls" under "WHISPER ROLLS TO GM" in the Default Sheet Settings Save Load your game Go to the settings tab on the right and scroll to the bottom where you will find a button that says Apply Default Settings. Press it. Choose to update the Whisper settings. Wait a minute or two for it to resolve. Have fun!
1589870482
Oosh
Sheet Author
API Scripter
You can also change the whisper type per-macro if you need to, for example: if you have a character called "Query" with their character sheet setting to always query whether to whisper, you can just put @{Query|wtype} at the start of a macro with a roll in it, it will query whether to make a public roll regardless of that character sheet's settings.
Keith, first off thanks for the stat block generator, and all the Stylus mods you have created, they are really helpful. I just noticed that "Deception" wasn't appearing in the stat block menu.  It looks like you are missing some brackets between Athletics and Deception... | [Athletics](~selected|npc_Athletics|Deception](~selected|npc_Deception) | Should be... | [Athletics](~selected|npc_Athletics ) | [ Deception](~selected|npc_Deception) |
1589883716

Edited 1589884211
I also noticed a minor niggle with the original macro, where you had to have the original token still selected in order to click on any of the links.  If you swapped to a different token, it would roll that token's stats instead of the one you displayed the stat block for. I've changed all mentions of ~selected to ~@{selected|character_name}, which means that the stat block in the chat will work correctly even after you have unselected the token, or selected a different one.  Full macro here, which also includes the Deception fix. EDIT... I also noticed you had npc_dec instead of npc_dex.  Also fixed below... /w gm &{template:npcaction}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type} **HP: **@{selected|bar1} / @{selected|hp|max} | ** AC: ** @{selected|npc_ac} | **Spd: ** @{selected|npc_speed} **Languages: **@{selected|npc_languages} **Senses: **@{selected|npc_senses} **Resists:: **@{selected|npc_resistances} **Immune: **@{selected|npc_immunities} **Cond. Immune: **@{selected|npc_condition_immunities}}}{{description=**Abilities** [**Str @{selected|strength}** *(@{selected|strength_mod})*](~@{selected|character_name}|npc_str) | [save](~@{selected|character_name}|npc_str_save) [**Dex @{selected|dexterity}** *(@{selected|dexterity_mod})*](~@{selected|character_name}|npc_dex) | [save](~@{selected|character_name}|npc_dex_save) [**Con @{selected|constitution}** *(@{selected|constitution_mod})*](~@{selected|character_name}|npc_con) | [save](~@{selected|character_name}|npc_con_save) [**Int @{selected|intelligence}** *(@{selected|intelligence_mod})*](~@{selected|character_name}|npc_int) | [save](~@{selected|character_name}|npc_int_save) [**Wis @{selected|wisdom}** *(@{selected|wisdom_mod})*](~@{selected|character_name}|npc_wis) | [save](~@{selected|character_name}|npc_wis_save) [**Cha @{selected|charisma}** *(@{selected|charisma_mod})*](~@{selected|character_name}|npc_cha) | [save](~@{selected|character_name}|npc_cha_save) **Skills** [Acrobatics](~@{selected|character_name}|npc_Acrobatics) | [Animal Handling](~@{selected|character_name}|npc_Animal_Handling) | [Arcana](~@{selected|character_name}|npc_Arcana) | [Athletics](~@{selected|character_name}|npc_Athletics) | [Deception](~@{selected|character_name}|npc_Deception) | [History](~@{selected|character_name}|npc_History) | [Insight](~@{selected|character_name}|npc_Insight) | [Intimidation](~@{selected|character_name}|npc_Intimidation) | [Investigation](~@{selected|character_name}|npc_Investigation) | [Medicine](~@{selected|character_name}|npc_Medicine) | [Nature](~@{selected|character_name}|npc_Nature) | [Perception](~@{selected|character_name}|npc_Perception) | [Performance](~@{selected|character_name}|npc_Performance) | [Persuasion](~@{selected|character_name}|npc_Persuasion) | [Religion](~@{selected|character_name}|npc_Religion) | [Sleight of Hand](~@{selected|character_name}|npc_Sleight_of_Hand) | [Stealth](~@{selected|character_name}|npc_stealth) | [Survival](~@{selected|character_name}|npc_survival) **Actions** [@{selected|repeating_npcaction_$0_name}](~@{selected|character_name}|repeating_npcaction_$0_npc_action) [@{selected|repeating_npcaction_$1_name}](~@{selected|character_name}|repeating_npcaction_$1_npc_action) [@{selected|repeating_npcaction_$2_name}](~@{selected|character_name}|repeating_npcaction_$2_npc_action) [@{selected|repeating_npcaction_$3_name}](~@{selected|character_name}|repeating_npcaction_$3_npc_action) [@{selected|repeating_npcaction_$4_name}](~@{selected|character_name}|repeating_npcaction_$4_npc_action) }}
1589889578

Edited 1589890304
Is there a way to adapt this macro for player use? I tried with the npc_.* strings, but it does not take into account trained skills, only the basic bonus edit: should have tried just putting in random values, figured it out soon after posting :P I just had to replace , e.g. npc_str with strenght , npc_str_save with strenght_save and finally npc_Acrobatics with Acrobatics.
1589914503
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks Alan, that was a great suggestion for using @{selected|character_name}. I'd gotten so used to just "knowing" how it works that I hadn't even consider that it might trip people up. And it keeps the macro "live". And also thanks for the proofreading. I can't believe I missed those bits. The code in the top post now shows those changes.
Can someone fix this one for me? I'm getting a weird whisper at the end. /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$0_name}}} {{description=@{selected|repeating_npctrait_$0_desc}}} /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$1_name}}} {{description=@{selected|repeating_npctrait_$1_desc}}} /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$2_name}}} {{description=@{selected|repeating_npctrait_$2_desc}}}
1589951773
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
It looks like you have an extra line in the macro. That will display in chat.
1593015627

Edited 1594478750
Oosh
Sheet Author
API Scripter
Suppressing lines with broken links - NPC Action Block & Spellbook Right, so after a bit of mucking about I've arrived at this method of only printing button links with valid actions attached. This requires CSS changes or the macro won't achieve anything. I won't cover Stylus changes because Keith has already done that . This also assumes you already have his Inline Links I'll also not post full macros here, just a snippet from each one. This Stylus code will only affect the npcaction template - it's easy enough to see where to alter it if you wish to use a different one. I narrowed it down to one template because it has the side-effect of removing ALL blank lines in the template - if you want a line break in an npcaction template after making this change, you will need to put a   on that line in your code or it will be hoovered up. So, the Stylus code: .sheet-rolltemplate-npcaction a[href*="|errselected"] { display:none !important; } .sheet-rolltemplate-npcaction br { margin-top: 0px; margin-bottom: 0px; display:block; content: ""; } followed by the altered macro code: /w gm &{template:npcaction} &{noerror} {{rname=@{selected|character_name}}} {{name=@{selected|npc_type}}} {{description= [@{selected|repeating_npcaction_$0_name} ](~@{selected|character_name}|err@{selected|repeating_npcaction_$0_name|max}|repeating_npcaction_$0_npc_action) [@{selected|repeating_npcaction_$1_name} ](~@{selected|character_name}|err@{selected|repeating_npcaction_$1_name|max}|repeating_npcaction_$1_npc_action) [@{selected|repeating_npcaction_$2_name} ](~@{selected|character_name}|err@{selected|repeating_npcaction_$2_name|max}|repeating_npcaction_$2_npc_action) [@{selected|repeating_npcaction_$3_name} ](~@{selected|character_name}|err@{selected|repeating_npcaction_$3_name|max}|repeating_npcaction_$3_npc_action) [@{selected|repeating_npcaction_$4_name} ](~@{selected|character_name}|err@{selected|repeating_npcaction_$4_name|max}|repeating_npcaction_$4_npc_action) [@{selected|repeating_npcaction_$5_name} ](~@{selected|character_name}|err@{selected|repeating_npcaction_$5_name|max}|repeating_npcaction_$5_npc_action) }} Will (hopefully!) result in this output, with $3, $4, $5 all suppressed in this example: The link ignores the bolded bit in between the central pipes , which means we can put whatever we want in there, then use the CSS a[href] selector to remove them. You can probably throw any repeating field in there, provided it has no value set (not even a blank) it will just output the text in the attempted Attribute call. The {name|max} field is probably best, as very few fields are actually created for blank NPC sheets: most of them are attack-related and may not populate if the ability has no attack. This spellbook macro works with the same Stylus code from above: /w gm &{template:npcaction}&{noerror}{{rname=@{selected|character_name}}}{{name=@{selected|npc_type}}}{{description=**Caster Level: @{selected|caster_level}** **Spell Save DC: @{selected|spell_save_dc}** **Spellcasteing Ability Mod: [[@{selected|spellcasting_ability}@{selected|pb}]]** **Level 1** [@{selected|repeating_spell-1_$0_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$0_spellprepared}prep|repeating_spell-1_$0_spell) [@{selected|repeating_spell-1_$1_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$1_spellprepared}prep|repeating_spell-1_$1_spell) [@{selected|repeating_spell-1_$2_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$2_spellprepared}prep|repeating_spell-1_$2_spell) [@{selected|repeating_spell-1_$3_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$3_spellprepared}prep|repeating_spell-1_$3_spell) [@{selected|repeating_spell-1_$4_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$4_spellprepared}prep|repeating_spell-1_$4_spell) [@{selected|repeating_spell-1_$5_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$5_spellprepared}prep|repeating_spell-1_$5_spell) [@{selected|repeating_spell-1_$6_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$6_spellprepared}prep|repeating_spell-1_$6_spell) [@{selected|repeating_spell-1_$7_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$7_spellprepared}prep|repeating_spell-1_$7_spell) [@{selected|repeating_spell-1_$8_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$8_spellprepared}prep|repeating_spell-1_$8_spell) [@{selected|repeating_spell-1_$9_spellname} ](~@{selected|character_name}|err@{selected|repeating_spell-1_$9_spellprepared}prep|repeating_spell-1_$9_spell) }} Should output to this, with most of the repeating fields suppressed: Bonus points to the Lich for having a blank spellname in one of the repeating field sections, as Keith discovered. Ok, now for bonus magic time! Spellbook Macro to only display Prepared spells So we now only need a tiny extra bit of Stylus code to remove all unprepared spells. This requires the above macro syntax and the above Stylus code: .sheet-rolltemplate-npcaction a[href*="|err0prep"] { display:none !important; } And your output should look like this: One issue with the Prepared Spell filtering: - if you are DM, this will hide ALL unprepared spells even for classes which don't prepare spells. If you have a common mook or a companion NPC who uses prepared spells a lot, and you only want them to list their prepared spells, you can tweak the selector to this: .sheet-rolltemplate-npcaction a[href*=" Bob |err0prep"] { display:none !important; } And the Prepared filtering will only apply to Bob (case sensitive). But you need to use the linking style from above which has ~@{selected|character_name} at the start of the link, instead of just ~selected. If you get errors thrown in chat after saving as a Collections or Ability macro, running it from another macro with #NPCaction &{noerror} should do the trick. Probably advisable to also apply the Stylus changes to URLs with regexp .*:\/\/((app\.|)roll20\.net([\/]?|\/editor.*|))$ Cheers to Tulty for testing it and finding a couple of issues - hopefully fixed now.
1593017518
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Now awarded to Oosh, the Galactic Institute's Prize for Extreme Cleverness! That's pretty brilliant. I tried to mess with it by setting display to "none" or adjusting line height but I couldn't improve it. I'm going to let this sit for a day or so in case anyone else out there has flashes of keen insight like this, or if you discover the spell solution, and then edit this into the source code and give the credited css lines as well.
1593018685
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hmm. on further testing I am seeing an issue. When run from the edit box, or pasted directly into chat, the code works fine. When run from a macro button, it produces out-of-template error messages for the missing attributes. Also, for some reason, the actions of some creatures continue to display, but as completely broken links. The example I found was the lich.
1593020147
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The "no attribute" flags can be suppressed by calling the macro from another macro which has ${no-error} in it. Example: if macro is called Statblock, the button it creates will show the errors. If you run it from a button created by another macro, whose code is: #Statblock &{noerror} it will run without errors
1593020291

Edited 1593610709
Oosh
Sheet Author
API Scripter
Hrmmmm... the Lich one can be fixed by adding   at the end of the button name.... for some reason the Lich has blank action-name entries in the missing abilities. Probably something got deleted. So this: - SNIP - obsolete on each line should prevent empty button labels. As for &{noerror}, I've always found it frustrating. I just don't get why it sometimes doesn't work. But anyway, this workaround should do the trick. A second macro with #macroname&{noerror} seems to work. I still have not got the foggiest idea how to get &{noerror} to play nice with @{target} macros though.
1593026431

Edited 1593030735
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
display:none; does help keep the non-existent links from even being clickable, but that only styles the <a> tag, not the <br> tag, which is causing the line spacing. I can't work out a br:before that will catch those.
I noticed that there's one NPC stat missing: Damage Vulnerability. Here's my slightly modified example (I removed the actions/traits/etc. to put them into a separate macro). /w gm &{template:npcaction} &{noerror}{{rname=@{selected|npc_name}}}{{name=@{selected|npc_type} **HP: **@{selected|bar1} / @{selected|hp|max} | ** AC: ** @{selected|npc_ac} | **Spd: ** @{selected|npc_speed} **Languages: **@{selected|npc_languages} **Senses: **@{selected|npc_senses} **Dmg. Res.:** @{selected|npc_resistances} **Dmg. Vuln.:** @{selected|npc_vulnerabilities} **Dmg. Imm.:** @{selected|npc_immunities} **Cond. Imm.:** @{selected|npc_condition_immunities}}}{{description=**Abilities** [**Str @{selected|strength}** *(@{selected|strength_mod})*](~@{selected|character_name}|npc_str) | [save](~@{selected|character_name}|npc_str_save) [**Dex @{selected|dexterity}** *(@{selected|dexterity_mod})*](~@{selected|character_name}|npc_dex) | [save](~@{selected|character_name}|npc_dex_save) [**Con @{selected|constitution}** *(@{selected|constitution_mod})*](~@{selected|character_name}|npc_con) | [save](~@{selected|character_name}|npc_con_save) [**Int @{selected|intelligence}** *(@{selected|intelligence_mod})*](~@{selected|character_name}|npc_int) | [save](~@{selected|character_name}|npc_int_save) [**Wis @{selected|wisdom}** *(@{selected|wisdom_mod})*](~@{selected|character_name}|npc_wis) | [save](~@{selected|character_name}|npc_wis_save) [**Cha @{selected|charisma}** *(@{selected|charisma_mod})*](~@{selected|character_name}|npc_cha) | [save](~@{selected|character_name}|npc_cha_save) **Skills** [Acrobatics](~@{selected|character_name}|npc_Acrobatics) | [Animal Handling](~@{selected|character_name}|npc_Animal_Handling) | [Arcana](~@{selected|character_name}|npc_Arcana) | [Athletics](~@{selected|character_name}|npc_Athletics) | [Deception](~@{selected|character_name}|npc_Deception) | [History](~@{selected|character_name}|npc_History) | [Insight](~@{selected|character_name}|npc_Insight) | [Intimidation](~@{selected|character_name}|npc_Intimidation) | [Investigation](~@{selected|character_name}|npc_Investigation) | [Medicine](~@{selected|character_name}|npc_Medicine) | [Nature](~@{selected|character_name}|npc_Nature) | [Perception](~@{selected|character_name}|npc_Perception) | [Performance](~@{selected|character_name}|npc_Performance) | [Persuasion](~@{selected|character_name}|npc_Persuasion) | [Religion](~@{selected|character_name}|npc_Religion) | [Sleight of Hand](~@{selected|character_name}|npc_Sleight_of_Hand) | [Stealth](~@{selected|character_name}|npc_stealth) | [Survival](~@{selected|character_name}|npc_survival)}}
1593182445
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks, Jarren!
1593257767

Edited 1593259089
Trying to incorporate the traits into your original macro but I can't get them to work. **Traits** [@{selected|repeating_npctrait_$0_name}](~@{selected|character_name}|repeating_npctrait_$0_-npc_roll_output) [@{selected|repeating_npctrait_$1_name}](~@{selected|character_name}|repeating_npctrait_$1_-npc_roll_output) [@{selected|repeating_npctrait_$2_name}](~@{selected|character_name}|repeating_npctrait_$2_-npc_roll_output) [@{selected|repeating_npctrait_$3_name}](~@{selected|character_name}|repeating_npctrait_$3_-npc_roll_output) [@{selected|repeating_npctrait_$4_name}](~@{selected|character_name}|repeating_npctrait_$4_-npc_roll_output) Links get created correctly but I get a "No ability was found for %{@selected|character_name} when clicking on them. I can call them okay with a different macro however. /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$0_name}}} {{description=@{selected|repeating_npctrait_$0_desc}}} /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$1_name}}} {{description=@{selected|repeating_npctrait_$1_desc}}} /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$2_name}}}{{description=@{selected|repeating_npctrait_$2_desc}}} /w gm &{template:npcaction} {{name=@{selected|npc_name}}} {{rname=@{selected|repeating_npctrait_$3_name}}}{{description=@{selected|repeating_npctrait_$3_desc}}} What am I missing? Thanks!
1593273628
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Not sure. Your first code works for me on a test kobold. Are you sure you were using it on an NPC and not a PC? Also, due to a change earlier this year,  repeating_npctrait_$3_desc  in your second macro should be changed to  repeating_npctrait_$3_description . Desc will still work on older characters, but has been deprecated. New characters will not have that attribute and will only return Description.
Thanks for the heads up on description vs desc! It is indeed on an NPC. However I sort of forgot that I'm running it on the AIME character sheet which is based on the 5E sheet but a bit older. I'm starting to think there may be enough differences to cause random issues like this. 
1593282515
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks, that clarifies a lot. If it's based on the legacy D&D 5th Edition by Roll20 Sheet, then yeah, I believe desc still works. But I think repeating_npctrait_$0_-npc_roll_output was added afterward as part of the same change. Before you had to put the desc field into a roll template field in order to have it report.
Yeah that is exactly how its acting and explains why it shows up in the roll-template based macro. Now need to learn how to upgrade or create character sheets; or just settle for the simpler macro.  I expect it'll be the latter!  Thanks for your time and your work!
1593366985
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yeah, unfortunately, the legacy sheet is the last public code. I don't know if it's possible to "reverse engineer" the current sheet.