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

Repeating attacks and &{noerror}

Hi all My players like to hold on to a lot of gear, after all you never know when that rusty dagger from the garderobe might come in handy at level 12 eh?  I want to eventually have a macro on a mule that can be called when they don't want to use their default weapon attack and am aware that &{noerror} doesn't always behave and the fix is to have a macro call a macro (? still true?) anyway, I have this %{selected|Attack} &{noerror} that calls this /w @{selected|character_name} &{template:npcaction} &{noerror}{{rname=Attacks}} {{description=Select Attack [@{selected|repeating_attack_$0_atkname}](~selected|repeating_attack_$0_attack) [@{selected|repeating_attack_$1_atkname}](~selected|repeating_attack_$1_attack) [@{selected|repeating_attack_$2_atkname}](~selected|repeating_attack_$2_attack) [@{selected|repeating_attack_$3_atkname}](~selected|repeating_attack_$3_attack) [@{selected|repeating_attack_$4_atkname}](~selected|repeating_attack_$4_attack) [@{selected|repeating_attack_$5_atkname}](~selected|repeating_attack_$5_attack) [@{selected|repeating_attack_$6_atkname}](~selected|repeating_attack_$6_attack) [@{selected|repeating_attack_$7_atkname}](~selected|repeating_attack_$7_attack) [@{selected|repeating_attack_$8_atkname}](~selected|repeating_attack_$8_attack) [@{selected|repeating_attack_$9_atkname}](~selected|repeating_attack_$9_attack) [@{selected|repeating_attack_$10_atkname}](~selected|repeating_attack_$10_attack) [@{selected|repeating_attack_$11_atkname}](~selected|repeating_attack_$11_attack) [@{selected|repeating_attack_$12_atkname}](~selected|repeating_attack_$12_attack) [@{selected|repeating_attack_$13_atkname}](~selected|repeating_attack_$13_attack) [@{selected|repeating_attack_$14_atkname}](~selected|repeating_attack_$14_attack) [@{selected|repeating_attack_$15_atkname}](~selected|repeating_attack_$15_attack) [@{selected|repeating_attack_$16_atkname}](~selected|repeating_attack_$16_attack) [@{selected|repeating_attack_$17_atkname}](~selected|repeating_attack_$17_attack) [@{selected|repeating_attack_$18_atkname}](~selected|repeating_attack_$18_attack) [@{selected|repeating_attack_$19_atkname}](~selected|repeating_attack_$19_attack) [@{selected|repeating_attack_$20_atkname}](~selected|repeating_attack_$20_attack)}} &{noerror} and it functions, but leaves ugly errors where no corresponding entry exists, so &{noerror} doesn't seem to be working asking me to make a macro is like asking a Discworld Igor to make friends, lots of parts are involved and much stitching together... can anyone point out the error of my ways (soz, not up to his standard) GNU Terry Pratchett
1686250579

Edited 1686250601
You are correct that there’s a bug where &{noerror} does not work unless it is used in a macro calling another macro. But that’s not what is happening here. This isn’t a bug… it just isn’t a feature that is enabled for this specific type of error.  The &{noerror} suppresses other error messages, but not the “no attribute found” errors. If you remove the &{noerror} then you’ll see even more error messages that are correctly being suppressed.   You may be interested in my  Universal Macro Mule for D&D 5E  approach, as it will give you an output of all the attacks on a PC sheet, without giving error messages for empty attributes. 
Thanks Jarren, swift and comprehensive reply as always, much appreciated.  A macro mule is definitely where I want to go- I picked up yours and one other recently, but I really want to learn how to write this for myself too - teach a chap to fish n all that
1686252717

Edited 1686252798
Gauss
Forum Champion
Here is my hacked together code for it. (Based on something Oosh wrote for me for 5e spell lists.) /w @{selected|character_name} &{template:npcaction} {{rname=@{selected|character_name}}} {{description=[-- Actions --](" style="background: none; background-color: transparent; border: none; padding: 0px; text-decoration: none; display:none; color: #7e2d40; font-weight: bold; display:none; display: block@{selected|repeating_attack_$0_atkname|max};) [@{selected|repeating_attack_$0_atkname} ](~@{selected|character_name}|repeating_attack_$0_attack" style="background: none; background-color: transparent; border: none; padding: 0px; text-decoration: none; color: purple; display:none; display: block@{selected|repeating_attack_$0_atkname|max}; )[@{selected|repeating_attack_$1_atkname} ](~@{selected|character_name}|repeating_attack_$1_attack" style="background: none; background-color: transparent; border: none; padding: 0px; text-decoration: none; color: purple; display:none; display: block@{selected|repeating_attack_$1_atkname|max}; )}}&{noerror} Adding more lines is easy (I only included two for this example). Yes, it still requires being called by a second macro to make &{noerror} actually work.  Colors can be edited.  My understanding (poor that it is) is that the CSS is what is preventing the lines from showing up if there is nothing there.  This section I think:  display:none; display: block@{selected|repeating_attack_$1_atkname|max} Here is the NPC version:  /w @{selected|character_name} &{template:npcaction} {{rname=@{selected|character_name}}} {{description=[-- Actions --](" style="background: none; background-color: transparent; border: none; padding: 0px; text-decoration: none; display:none; color: #7e2d40; font-weight: bold; display:none; display: block@{selected|repeating_npcaction_$0_name|max};)[@{selected|repeating_npcaction_$0_name} ](~@{selected|character_name}|repeating_npcaction_$0_npc_action" style="background: none; background-color: transparent; border: none; padding: 0px; text-decoration: none; color: purple; display:none; display: block@{selected|repeating_npcaction_$0_name|max}; )[@{selected|repeating_npcaction_$1_name} ](~@{selected|character_name}|repeating_npcaction_$1_npc_action" style="background: none; background-color: transparent; border: none; padding: 0px; text-decoration: none; color: purple; display:none; display: block@{selected|repeating_npcaction_$1_name|max}; )}}&{noerror}
Some swift cut n pasting and away we go rejoicing - thanks Gauss, job's a fish.  That gets me in a place where I can thin out the token actions and just have some general macros in the macro bar.  Now to make those buttons smaller...
1686269857

Edited 1686269900
Ah gotcha. If you’re interested in how I suppressed error messages from items that don’t exist, then I suggest diving into my code to see the trickery at play. It primarily uses Oosh’s  HTML Styles in Chat  trick   For example, PCAttackList has (it has more, but this is the first item):  [-- Attacks --](%{MM|StatLinkStyle} display: block;) [ ](%{MM|BreakLinkStyle} display: block;)[@{selected|repeating_attack_$0_atkname} ](~@{selected|character_name}|repeating_attack_$0_attack%{MM|ActionLinkStyle} display: inline-block@{selected|repeating_attack_$0_atkname|max}; )[ ](%{MM|BreakLinkStyle} display: block@{selected|repeating_attack_$0_atkname|max}; ) So the breakdown looks like this: Header: [-- Attacks --](%{MM|StatLinkStyle} display: block;) %{MM|StatLinkStyle} contains: " style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 13px; display:none; color: #7e2d40; font-weight: bold; white-space: pre; Line break that only appears when there is a repeating attack “0”   [ ](%{MM|BreakLinkStyle} display: block;) %{MM|BreakLinkStyle} Contains:  " style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 13px;  display:none;  height: 0.0px; The name of the attack (braces to indicate what is displayed in the button): [@{selected|repeating_attack_$0_atkname} ] Is to link the button to the attack roll (the parentheses indicate what happens when the button is clicked) ~@{selected|character_name}|repeating_attack_$0_attack Make it so that the attack only displays when it is present: %{MM|ActionLinkStyle} display: inline-block@{selected|repeating_attack_$0_atkname|max}; ) %{MM|ActionLinkStyle} contains: " style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 13px;  display:none;  color: red; Since %{MM|ActionLinkStyle}  has ‘display:none;’, nothing will be displayed by default. But then there’s another ‘display:inline’ afterwards that has the ‘attackname|max’ attribute immediately after the ‘inline’ and before the closing semicolon ';'. That means that if there is an attack in the ‘0’ position (the first attack on a sheet), there will be an ’attackname’ attribute. The ‘max’ field for attributes is always present, but almost never used (exceptions are things like HP), so it will be empty. Since it is empty, you get ‘display:inline;’ which then causes the item to be displayed. HTML/CSS rules basically always follow whatever the last attribute is for an element - the 'display: none;' gets replaced by 'display: inline;' - unless the attribute is invalid, which is what happens when there's no attack in the '0' position.  What the browser sees is ' display: inline-blockERRORMESSAGE;'. My approach is basically the same as what Gauss provided, except that a lot of the repeating portions of code are put into MacroMule abilities, so you don't have to copy and paste '" style="text-decoration: none; background: none; background-color: transparent; border: none; padding: 0px; font-size: 13px; display:none; ' over and over. Then I also made it so that buttons are created that link to each other (what is shown in the footer). And lastly there are attributes that are simply used so that specific portions can be changed easily, such as the color of the buttons.  That way you don't have to copy all the code, search-and-replace for a color, and reupload the changed color code into the macromule.
Awesome, thank you. The support provided in these forums is second to none, thank you both for your time once again, very much appreciated