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 .
×
Stuck in a login loop? Try manually signing out and back in before launching your game. Otherwise, contact the Help Center!
Create a free account

Macro help needed. Me = bad coder w/ good intentions

1452850558

Edited 1452850805
New "MACRO / WEAPON ROLL MOD" question for you. First off, I'm a terrible coder...it's been 33 years since I've taken a coding class, so... I want to help a player with her sheet so that when she rolls a weapon attack, a Staff of Striking (w/Shillelagh cantrip), so that it asks her how many charges she wants to use for the attack (an input of 0-3). /me uses Force Charges from the Staff of Striking for [[?{How many charges (0-3)?}d6]] additional points of damage. First Question: I want to modify the above macro to put the input request earlier in the macro with a input user variable so it reads "(player name) uses (x=input#) Force Charges from the Staff of Striking for ("x"d6) additional points of damage." Second Question: Can the buttons on the 5E sheet be modified to include a call out to this macro so that when she rolls the attack button, it completes the roll and then executes the above macro? Here is the button data: <button type="roll" name="roll_MeleeAttack1" value="&{template:5eDefault} {{weapon=1}} {{title=@{meleeweaponname1}}} {{subheader=@{character_name}}} {{subheaderright=Melee attack}} {{attack=[[1d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{attackadv=[[1d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{damage=[[@{meleedmg1} + @{meleedmgbonus1} + (@{global_melee_damage_bonus}) + 0d0]] @{meleedmgtype1}}} {{critdamage=Additional [[@{meleecritdmg1}]] damage}} @{classactionmeleeweapon}}">Attack</button> Bonus Idea / Question:  Could one actually create an attribute for CHARGES on the Staff and use the variable in the macro to track its use and, if the # of charges = 0, automatically roll a 1d20 roll (1, the staff loses the power permanently), else state that "the staff is out of charges for the day"? I guess I would also need a way to add "new day charges" back to the staff, too....getting really complicated, right? Thanks, all. Sal
1452864072

Edited 1452864495
Sal90066 said: First Question: I want to modify the above macro to put the input request earlier in the macro with a input user variable so it reads "(player name) uses (x=input#) Force Charges from the Staff of Striking for ("x"d6) additional points of damage." Player uses ?{How many charges|0|1|2|3} Force Charges from the Staff of Striking for [[ ?{How many charges}d6 ]] additional points of damage. Sal90066 said: Second Question: Can the buttons on the 5E sheet be modified to include a call out to this macro so that when she rolls the attack button, it completes the roll and then executes the above macro? Here is the button data: <button type="roll" name="roll_MeleeAttack1" value="&{template:5eDefault} {{weapon=1}} {{title=@{meleeweaponname1}}} {{subheader=@{character_name}}} {{subheaderright=Melee attack}} {{attack=[[1d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{attackadv=[[1d20cs>@{meleeweaponcritrange1} + @{meleetohit1} + (@{global_melee_attack_bonus}) ]]}} {{damage=[[@{meleedmg1} + @{meleedmgbonus1} + (@{global_melee_damage_bonus}) + 0d0]] @{meleedmgtype1}}} {{critdamage=Additional [[@{meleecritdmg1}]] damage}} @{classactionmeleeweapon}}">Attack</button> I recommend that you use a class action under the Class tab for this (and set its output options to Melee Weapons); much simpler.
As far as your bonus question, you cannot automatically modify attributes without the help of an API script to do so.  There are API solutions, but they can get rather complex, much more so than the macro options presented above.
Silvyre said: I recommend that you use a class action under the Class tab for this (and set its output options to Melee Weapons); much simpler. The less-simple option is to copy and paste the following into the Damage Type field: bludgeoning }} ?{How many charges| 0, | 1, {{Staff of Striking=Player uses 1 Force Charge from the Staff of Striking for [[ 1d6 ]] additional points of damage. | 2, {{Staff of Striking=Player uses 2 Force Charges from the Staff of Striking for [[ 2d6 ]] additional points of damage. | 3, {{Staff of Striking=Player uses 3 Force Charges from the Staff of Striking for [[ 3d6 ]] additional points of damage. } }}
1452884414

Edited 1452884461
Dear Kevin & Silvyre, Thanks for the responses.  I placed the code in the DAMAGE TYPE cell/field for the Weapon. I also changed the code slightly so that an input of 0 would state "...doesn't use any Force Charges." bludgeoning }} ?{How many charges| 0, {{Staff of Striking=Nasaero doesn't use any Force Charges.| 1, {{Staff of Striking=Player uses 1 Force Charge from the Staff of Striking for [[ 1d6 ]] damage. | 2, {{Staff of Striking=Player uses 2 Force Charges from the Staff of Striking for [[ 2d6 ]] damage. | 3, {{Staff of Striking=Player uses 3 Force Charges from the Staff of Striking for [[ 3d6 ]] damage. } }} I then went to the Attributes tab and set the classactionrecharge1 = 10 / 10; then, in the Token settings, I set the RED bar to classactionrecharge1 (I usually use this bar for speed, but this is a better use for this token). How would one add a function to the above code to decrement the #ofCharges by the input used? I'm guessing that at the end of each string, following "[[1d6]] damage.", this is where the modifier would go - I simply don't know the syntax. I'm guessing for input value 1, "--classactionrecharge1", etc....I hope you understand where I'm going with this...
1452890626

Edited 1452890666
Assuming you're content with manually modifying that bar after using the macro (i.e. not using API Scripts): bludgeoning }} ?{How many charges| 0, {{Staff of Striking=Nasaero doesn't use any Force Charges. | 1, {{Staff of Striking=Nasaero uses 1 of @{classactionrecharge1} Force Charges for [[ 1d6 ]] damage and has [[ @{classactionrecharge1} - 1 ]] charges remaining. | 2, {{Staff of Striking=Nasaero uses 2 of @{classactionrecharge1} Force Charges for [[ 2d6 ]] damage and has [[ @{classactionrecharge1} - 2 ]] charges remaining. | 3, {{Staff of Striking=Nasaero uses 3 of @{classactionrecharge1} Force Charges for [[ 3d6 ]] damage and has [[ @{classactionrecharge1} - 3 ]] charges remaining. } }} Is this close to what you were looking for?
1452909694

Edited 1452910222
Actually, in function, no. The goal is: set x = classactionrecharge1; // store the Current Number of Force Charges in the Staff in variable "x" y = (input value of 0 to 3); // number of charges to use, function is performed set classactionrecharge1 = x - y; // Stores a new Current Number of Force Charges in the Staff AFTER this use What you have above never modifies the VALUE of classactionrecharge1 to reflect its use. The goal is to see the token's RED bar/value drop with use. Wow, so close...I can feel it crackling in the air! Thanks so much, BTW. -Sal
API Script route, then? I recommend Ammo .
Silvyre, Hmmm...how did we get there all of a sudden? So close... Can't we... A. take the input value B. calculate X & Y C. perform the text and rolls based on input value Am I missing something? Can't the value of classactionrecharge1 be modified via the above routine? -Sal
Kevin said: you cannot automatically modify attributes without the help of an API script
1453057610

Edited 1453110411
The Aaron
Pro
API Scripter
Sorry for the delay in posting (thanks for the ping, Sal!), been under the weather. If you want to do this with Ammo, it would look like: /em Player uses ?{How many charges|0|1|2|3} Force Charges from the Staff of Striking for [[ ?{How many charges}d6 ]] additional points of damage. !ammo @{character_id} chargesforstaff -?{How many charges} This is assuming the character in question has an attribute named chargesforstaff.  It will then decrement by the amount provided and report the amount remaining.  You can set the attribute max to the total number of charges.  It will give an error to the player running it and the gm and not make a change if there aren't enough charges.  You can recharge by adding: !ammo @{character_id} chargesforstaff +[[1d6+4]] and it will fill up to the max. The gm is not restricted when running the commands. [sneaky edit to correct spelling error in code example] - Z