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

Trying to get this to work right, not sure how (I suck with code!)

So I've got this macro that I've been trying to get to work reliably for a while now. In my game, there's a warrior who is focused around charging opponents, smashing them into walls, using Leap Attack for bonus damage and placement.. This is what I've got so far: &{template:default} {{name=Attack}} Power Attack Penalty=[[?{PA|0}]] Charging = [[+?{Charge Bonus?:|Yes,4|No,0} ]] Leap Attack = [[?{Leap Attack?:|Yes,3|No,1}]] First Attack=[[1d20+13 -?{PA|0} +?{Charge Bonus|0}]] Second Attack=[[1d20+8 -?{PA|0}]] First Damage= [[1d10+6 + 2*?{PA|0}*?{Leap Attack|1}]] Second Damage= [[1d10+6 + 2*?{PA|0}]] Now, what this does so far is ask what the power attack penalty is, then if they're charging, and then if they're leap attacking. Then it asks for the charge bonus and the leap attack multiplier. Due to some (custom) equipment, his total charge bonus is 4, and the leap attack multiplier (because he's using a two-handed weapon) is 3. Is there a way to get it to stop asking for the charge bonus and the leap attack multiplier, especially since they're been put into the dropdown values? Any help would be appreciated.
For informational purposes, even when 'No' is selected on the two dropdowns, it still asks for the Charge and Leap Attack values.
1527454557

Edited 1527454573
GiGs
Pro
Sheet Author
API Scripter
This is because of the ?:  in the first two versions of the modifier, which are part of the modifier name so are seen as different queries from the  second instances. Make them the same, like so: &{template:default} {{name=Attack}}  Power Attack Penalty=[[?{PA|0}]] Charging = [[+?{Charge Bonus?|Yes,4|No,0} ]] Leap Attack = [[?{Leap Attack?|Yes,3|No,1}]] First Attack=[[1d20+13 -?{PA|0} +?{Charge Bonus?}]] Second Attack=[[1d20+8 -?{PA|0}]] First Damage= [[1d10+6 + 2*?{PA|0}*?{Leap Attack?}]] Second Damage= [[1d10+6 + 2*?{PA|0}]] You also dont need the |0 part in the second version of the queries.  Also, unrelated, your template wont appear properly on output because you have split it across multiple lines and dont have {{ }} around each of the elements after the first. &{template:default} {{name=Attack}} {{Power Attack Penalty=[[?{PA|0}]] }} {{Charging = [[+?{Charge Bonus?|Yes,4|No,0} ]] }} {{Leap Attack = [[?{Leap Attack?|Yes,3|No,1}]]}} {{First Attack=[[1d20+13 -?{PA|0} +?{Charge Bonus?}]] }} {{Second Attack=[[1d20+8 -?{PA|0}]] }} {{First Damage= [[1d10+6 + 2*?{PA|0}*?{Leap Attack?}]]}} {{Second Damage= [[1d10+6 + 2*?{PA|0}]]}} I've included linebreaks in the above for clarity, but you should remove them in your macro.
Thank you for posting a working model of what I was trying to do! I'm no good with code, and none of the information I'm able to find online is very useful to me because it describes things I have no idea how to interperet (i.e. Boolean math). Now, correct me if I'm wrong, but it seems that the only difference between the two macros you posted is merely cosmetic, right? This might be a preference, but the second one seems messier than the first, if I may post results to compare.. vs Was this intentional in the construction, or was there to be a different effect?
1527457243
GiGs
Pro
Sheet Author
API Scripter
The second version should look like this, if you have removed all linebreaks: You could look at combining some of those on the same line, like so: &{template:default} {{name=Attack}} {{Power Attack=[[-?{PA|0}]] }} {{Charging: +[[?{Charge Bonus?|Yes,4|No,0}]]=Leaping: [[?{Leap Attack?|Yes,3|No,1} ]] }} {{Attack 1: AC [[1d20+13 -?{PA|0} +?{Charge Bonus?}]]=Damage: [[1d10+6 + 2*?{PA|0}*?{Leap Attack?}]]) }} {{Attack 2: AC [[1d20+8 -?{PA|0}]]=Damage: [[1d10+6 + 2*?{PA|0}]] }} This would produce something like:
Ok, so I'm sure I understand entirely.. What do you mean by Linebreak? I'm THAT MUCH of a newbie at this stuff. :D
1527467124
GiGs
Pro
Sheet Author
API Scripter
You know at the end of a sentence, you hit Return to create a new line? Like so. That's a linebreak. You need to ensure that there are no linebreaks in the macro, and it only goes onto a new line because it wraps naturally, because the line is long, like this one. If your macro is crossing multiple lines, position your mouse cursor at the end of each line and press delete, to force the next line to join that one. If this removes any characters, retype them.  So if you have something like this: &{template:default} {{name=Attack}} {{Power Attack=[[-?{PA|0}]] }} You'd put the mouse at the end of the first line, type delete. Sometimes this will delete the first character of the next line, so you end up with this: &{template:default} {{name=Attack}} {Power Attack=[[-?{PA|0}]] }} Notice the first curly bracket has been deleted? Just watch out for that happening and retype in the missing character when it does. Once that's done you'll have it all one one line (it will appear to wrap into multiple lines to fit into the macro box, but as far as roll20 is concerned, it's a single line).
Thank you for patiently explaining that to me. I hope to get better at this.
1527478237
GiGs
Pro
Sheet Author
API Scripter
You're welcome. There are people at every level of experience here, so don't worry about it. You'll get better. It just takes time and practice.