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

3.5 Help fix a macro

Just wondering if I could get some help here. I put this macro in the collections page and tried to call it in another macro, but something keeps going wrong. I replaced , } and | that I thought needed replacing, but it still doesn't work. Could you take a look at it and see if I missed any or explain what else I am doing wrong. /em @{selected|character_name} @{selected|weapon1type} their @{selected|weapon1name} at @{target|token_name} whose armor class is [[@{target|bar2}]] with a [[1d20cs>[[{(@{target|bar2}+10)-(20-@{selected|weapon1critmin})-(?{Form | Melee, [[@{selected|meleeattackbonus}]]  | Ranged, [[@{selected|rangedattackbonus}]]  } +@{selected|weapon1enh}+@{selected|weapon1focus}),0 } kh1 ]]+(?{Form | Melee, @{selected|meleeattackbonus}  | Ranged, @{selected|rangedattackbonus}  } +@{selected|weapon1enh}+@{selected|weapon1focus}),0 } kh1 ]] dealing [[{floor({@{selected|weapon1damage}+{@{selected|weapon1damagestat} } } )+@{selected|weapon1enh} +@{selected|weapon1specialize} } ,0 } kh1 ]] damage. /w gm @{selected|weapon1specialproperties} As it stands it is called, prompts you to choose a target, but then will not let you choose a target.
1558732972

Edited 1558733046
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Shem, It looks like you're aiming for advanced roll queries. This is a difficult process. I would recommend considering whether you need this to be a drop down, or could a chat menu work for you? If you are set on having this be a drop down query, I would recommend not storing the html escaped macro in the collections tab. The collections macro editor eats html replacements any time you open and resave the macro and this could be the cause of your problem. I would instead recommend utilizing a macro mule . In order to help you figure out what's missing, it would help to know what sort of error you are getting. I find a screen cap of what the drop down at each step of the nesting looks like to be the most helpful here. Additionally, I have made an html escaper specifically for query nesting , which you may find useful. EDIT: When you say it won't let you choose a target, what do you mean? do you have the crosshair mouse cursor, but it won't accept a click on a token?
"EDIT: When you say it won't let you choose a target, what do you mean? do you have the crosshair mouse cursor, but it won't accept a click on a token?" Exactly.
1558743152
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
hmm, ok, that's not an html code replacement issue. Some questions: What if you just do @{target|bar2}? Can you select the token you are trying to target?
Well, this is a macro for my players, so they would not be able to select their target.
1558752239
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No, I understood that. I was trying to figure out what was going on. For instance, are you on the right layer to interact with the token?
1558758292
Gen Kitty
Forum Champion
Players can select targets with macros, if the macro has items such as @{target|bar2}.
1558770549
Ziechael
Forum Champion
Sheet Author
API Scripter
It's a long standing issue(?) with incorrectly formatted macros, the target box hangs... technically it has accepted the target selection but because the macro has failed the box prompt doesn't go away and no error is reported to chat. As Scott says, you'll run into no end of problems trying to do this via a drop down, not least of which would be that if you ever tried to run this macro as a stand alone it would fail due to the html not  needing to be nested as a base macro. Could you share the macro you are using to call this one? While chat menus (as linked above) are your best bet... trust me, I've been where you are... you can still make this implementation work if you are truly determined :)
1558771355
Ziechael
Forum Champion
Sheet Author
API Scripter
I've built literally thousands of 3.5e macros and this one hurts my brain, could explain a bit about the intent of some of the code as I'm seeing at least three kh sections but only a couple of potential beginnings for them as a starter. Is this for a dagger or something that allows both a ranged and melee option as you are only ever looking at weapon 1's enhancement/focus/specialisation etc? Finally, what is in bar2 of the targets? Are you using a homebrewed crit calculation?
Okay, for some further disclosure.  I actually have ten macros that are identical, except that each calls a different weapon slot on the character sheet. This is the reason for the option of ranged or melee, as you choose your weapon and then state whether it is ranged or melee. The idea was to create a drop down menu so that I could have a single macro that could call any of the weapons on the character's list. As the macros are listed in the collections page, the macro to call them simply used the call for that. So #W01A, as the title of the macro, would call the weapon in slot one and perform an attack with it. To test this I simply typed #W01A into the chat log. The other macros are similarly titled but with the different numbers; so #W02A would call weapon 2, and so on. Also, I have checked the layers and I am in the proper lay to target the tokens. I actually was testing it by having the token that made the attack target themselves. And yes, I do use a custom critical system, which is the reason for the kh throughout the macro. In my game to get a critical you must defeat the AC by a certain amount (subtract 10 from the weapons normal critical range to determine this). I believe the kh had to be used because one of my players had enhanced himself to the point that against some targets he was getting a critical on a natural roll of -1, which caused the macro to fail. So I added the kh to ensure that 0 was the lowest calculation that could be rendered for this purpose. Finally, Bar2 of the target is simply their armor class. I placed it in bar2 so that I would have a quick reference to it without the need to constantly look at the character sheet. It is also bar2 so that I can place tokens that are not attached to character sheets and still give them an AC for the purpose of this macro. The main goal is to make a way for the players call any weapon on their list in a single macro. I am not familiar with the chat menus, but will look into it. If I can get it to work well than I have no problem with that. 
1558809667
Ziechael
Forum Champion
Sheet Author
API Scripter
Awesome, thanks for the context... it all makes a bit more sense to me now. I’ll try to get a working example for you sometime soon (away with just my phone for now so it might be a day or two)... it is 100% doable with the caveat that you will never be able to open the collection macros ever again without having the encoded macros stored elsewhere because the html will convert on opening.  Chat menus to take a bit of work but are much less upkeep overall... still this current avenue is an important one to explore for any budding macro writer! Hang in there, it gets easier ;)
Thank you.  I am well aware of the converting back on opening, though I forgot briefly as I haven't made any macros for some time. I have a whole set for my skills that are also in the collections, but which I have in a word document as well, so that I can make changes or replace as needed. Also, I looked at Scott's   html escaper specifically for query nesting , but I was unable to use it, as it is view only, and I couldn't see how to download it or anything. Just wondering if I might get a copy for myself.
1558818639
Ziechael
Forum Champion
Sheet Author
API Scripter
Shem A. said: Also, I looked at Scott's   html escaper specifically for query nesting , but I was unable to use it, as it is view only, and I couldn't see how to download it or anything. Just wondering if I might get a copy for myself. Exactly that, Scott has set to read only to keep it protected as a template. Load it up and 'make a copy' to get a fully editable version owned by you :)
I'm not used to google.docs. I don't use them very often.
1558827911
Ziechael
Forum Champion
Sheet Author
API Scripter
Assuming you are signed in to a google account with access to google drive you just go to 'make a copy': It will then add a fully editable copy of the sheet to your drive that you can do with as you please :)
I got it.
1558828798
Ziechael
Forum Champion
Sheet Author
API Scripter
Side note, starting to look at how to best implement your vision... do you make any changes to the sheets default values? I notice you use @{selected|weapon1damage} in your macro, this value is a macro in and of itself... this would result in a need to change the offending characters there as well... it also contains the @{weapon1damagestat} which you then use in your macro too?
1558833536
Ziechael
Forum Champion
Sheet Author
API Scripter
Starting to get somewhere... in addition to the above question, is your custom crit based on the overall result or the initial d20 roll?
I replace the damage macro with the base dice rolled (such as 1d6). It does contain the damage stat however. As to the critical, it is based on the total result. The problem I had in the past is that I had a character that was able to get a critical by defeating the AC by 3 or more, but they had a +17 to the attack roll. So, when they attacked a creature with an AC of 13 the macro calculated that any natural roll of -3 or higher would result in a critical, which made the macro simply render a 1 total every time for these low ACs.
1558881276
Ziechael
Forum Champion
Sheet Author
API Scripter
Cool, thought I was the only one who replaced the damage field with the basic dice :) That helps, thanks. Final Q, does a 1 still auto miss?
1558909441

Edited 1558909527
Yes. A natural 1 is a fumble. If they have no proficiency than a natural1 2 or 3 is a fumble.
1558994424
Ziechael
Forum Champion
Sheet Author
API Scripter
Ok, sorry it is taking so long... we've had house guests all weekend so I've not been able to be 'unsociable' as my wife would call it! Here is my current functioning version, this is standalone and not ready for nesting yet... but it works with the appropriate highlighting for both crits and crit fails: ! ?{Form|Melee,@{selected|meleeattackbonus}[Melee bonus]|Ranged,@{selected|rangedattackbonus}[Ranged bonus]} ?{Proficient|Yes,1[Proficient]|No,3[Not Proficient]} /em @{selected|character_name} @{selected|weapon1type} their @{selected|weapon1name} at @{target|token_name} whose armor class is [[ @{target|bar2} ]] with a [[ 1d20cs>[[ {@{target|bar2}[Target AC] + (@{selected|weapon1critmin}[Crit min] - 10 - ?{Form} - @{selected|weapon1enh}[Weapon Enh] - @{selected|weapon1focus}[Weapon Focus]),?{Proficient}}kh1]]cf<?{Proficient} + ?{Form} + @{selected|weapon1enh}[Weapon Enh] + @{selected|weapon1focus}[Weapon Focus] ]] dealing [[ { floor(@{selected|weapon1damage}[Weapon Damage] + @{selected|weapon1damagestat}[Weapon Damage Stat]) + @{selected|weapon1enh}[Weapon Enh] + @{selected|weapon1specialize}[Weapon Spec],0d0}kh1 ]] damage on a hit. /w gm @{selected|weapon1specialproperties} Next step... nesting that sucker!
1558995757
Ziechael
Forum Champion
Sheet Author
API Scripter
Ok, was getting some real funkiness with launching the macro directly from a weapon selection input... to get around that, and my current burgeoning headache, I present to you a pseudo-chat menu: /w "@{selected|character_name}" ?{Weapon|@{selected|weapon1name},[ATTACK!](!
#W01A)|@{selected|weapon2name},[ATTACK!](!
#W02A)} Obviously you can extend that to include all 10 weapon slots, those that are empty will show up as blank lines in the drop down menu but... meh, first world problems. The beauty of this approach is that the code supplied for the actual attack macro requires no html replacements so if you accidentally open it up from the collections menu you'll break literally nothing! It does add a button to click rather than selection>launch macro but it feels worth it in the long run from a maintenance perspective. Feel free to ask any and all questions about my last 2 posts, lots of funky little bits of info there for you :)
1558996663
Ziechael
Forum Champion
Sheet Author
API Scripter
Another potential option for you: /w "@{selected|character_name}" &{template:DnD35StdRoll} {{basicflag=true}} {{name=Choose Your Weapon}} {{notes=[@{selected|weapon1name}](!
#W01A) [@{selected|weapon2name}](!
#W02A) [@{selected|weapon3name}](!
#W03A) [@{selected|weapon4name}](!
#W04A) [@{selected|weapon5name}](!
#W05A) [@{selected|weapon6name}](!
#W06A)}} Works in much the same way as the query based pseudo-chat menu but generates an actual full list of clickable buttons for the weapons... the issue with this one is that any weapons with blank fields for names will show ugly code rather than blank lines... still, it's an option for the more indecisive members of your group ;)
Quick question: What makes the in chat menu work. Is it the " " or is there something else that I am missing. However, the menus still don't seem to work. It still is prompting to choose a target and then doing nothing. I don't know if you can see it in this screen shot, but the cross hairs on on the blue guy on the left, and yet when I click nothing happens.
1559029657

Edited 1559030043
Ziechael
Forum Champion
Sheet Author
API Scripter
The chat menu is driven by the slightly misnamed API buttons: [ATTACK!](!
#W01A) The [<name>] section details the label for the button while the (<code>) section is what the button does, in this case we have to use some html funkery to 'trick' the button: !
 #W01A, the bold bit is essentially telling the chat to insert a line break but the ! also tells it to not print the line break to chat... this then allows the macro call to run as if it were entered manually, on a new line. The " " just surrounds the name of who to whisper the menu to (to avoid chat clutter for everyone), it isn't always needed but helps protect against strange spacing or characters in the token's name. As for the functionality... Hmm strange, works perfectly for me: Are the macros being called by the buttons setup using the new code? Here is mine:  etc etc (click to enlarge)
No, I missed that part. Let me see if I understand how this is done. In the macro after each call (such as @{selected|weaponfocus}) I insert the same thing in single brackets: [weapon focus]. This is only when it is part of a calculation, and not when it is simply stating the number. So, when I want to state the AC of the target I simple put in [[@{target|bar2}]], but when I want as part of the calculation I put in @{target|bar2}[Target AC]. I will likely have other questions as well, but one at a time. Am I right so far. Just trying to get a handle on this. Also, I notice you put the option of ranged or melee before the actual calculation. This doesn't show up in the chat?
1559074515
Ziechael
Forum Champion
Sheet Author
API Scripter
Sorry, I do tend to over complicate things... even for a 'teaching moment' lol. The single brackets [labels] are simply for ease of readability when hovering over a calculated result, helps with debugging and ensuring things are coming through as expected. Diana's templates have these by default for things like power attack etc and I tend to use them in any complex macro so that I can 'read' the on-hover result. I also tend to put all my queries on a single line, in the order I want them to be asked, at the start of my macros so that I can control the order and get the messy bit out of the way. Preceding the line of the macro with a '!' tells it to read that line as a call to the API which (if you don't have pro or a script looking for an API call full of queries) will not output to the chat. It then means I only need to put ?{Query} as part of the macro itself to repeat the result from the 'hidden' query calls. It certainly takes some getting used to so please do keep asking questions and I'll do my best to answer in a way that actually makes sense!
In that case I think the macro is basically the same. I do just have a 0 instead of a 0d0 at the end. Maybe that is the trouble. I can't check it now, but I will let you know.
1559077497
Ziechael
Forum Champion
Sheet Author
API Scripter
Yup, that causes a silent fail. In isolation it will give the ‘cannot mix sum and m rolls’ or whatever it is when you try to mix rolls and non-rolls in kh/kl situation. Turning that to 0d0 should solve it.
Using just the 0 worked until I put it in the collections it seems. I originally had it in the Abilities page of the character sheet, with a separate token button for each weapon.
Could you post the macros your using in a way that I can copy and paste them. I want to get them in a document for easier comparison to what I am doing.
1559114894
Ziechael
Forum Champion
Sheet Author
API Scripter
Sure, the ones I posted several replies ago are the current working versions. They are in code blocks so should be easy to copy/paste. For the subsequent weapons I just put the attack macro into a text editing programme and do a find/replace on weapon1 to replace with weapon x .
The two chat menus I got. But the actual attack macros seem to be in a screen shot and I can't copy from that.
1559129754
Ziechael
Forum Champion
Sheet Author
API Scripter
It was the first post with a code block... but for ease: ! ?{Form|Melee,@{selected|meleeattackbonus}[Melee bonus]|Ranged,@{selected|rangedattackbonus}[Ranged bonus]} ?{Proficient|Yes,1[Proficient]|No,3[Not Proficient]} /em @{selected|character_name} @{selected|weapon1type} their @{selected|weapon1name} at @{target|token_name} whose armor class is [[ @{target|bar2} ]] with a [[ 1d20cs>[[ {@{target|bar2}[Target AC] + (@{selected|weapon1critmin}[Crit min] - 10 - ?{Form} - @{selected|weapon1enh}[Weapon Enh] - @{selected|weapon1focus}[Weapon Focus]),?{Proficient}}kh1]]cf<?{Proficient} + ?{Form} + @{selected|weapon1enh}[Weapon Enh] + @{selected|weapon1focus}[Weapon Focus] ]] dealing [[ { floor(@{selected|weapon1damage}[Weapon Damage] + @{selected|weapon1damagestat}[Weapon Damage Stat]) + @{selected|weapon1enh}[Weapon Enh] + @{selected|weapon1specialize}[Weapon Spec],0d0}kh1 ]] damage on a hit. /w gm @{selected|weapon1specialproperties}
Sorry, I have been rather tired lately with a new job and saw only two posts with code block. Thank you.
1559149501
Ziechael
Forum Champion
Sheet Author
API Scripter
No need to apologise, there is a lot to take in here :)