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

Combining multiple macros/scripts in a single macro

1624034698

Edited 1624035852
Can anyone help me understand why this macro for the Aid spell doesn't work consistently?  Sometimes it works fine and other times, the script doesn't completely work.  Can you not chain multiple things like repeating spells and API scripts?  Or is there a "correct" way or order to do this? But basically, the macro should: 1. Fire the Aid Spell off of the character sheet 2. Use token-mod to adjust the hp (bar1) of the three selected tokens by the correct amount based on the spell level selected from casting the spell and apply the green plus (aid-1) status marker to the three selected tokens 3. Whisper to the gm which characters were targeted by the Aid spell %{Elran|repeating_spell-2_-MZ2LiZRx77yY1iN5fEJ_spell} !token-mod {{ --ids @{target|1|token_id} @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set bar1_value|+[[5*?{Cast at what level?}-5]] --set bar1_max|+[[5*?{Cast at what level?}-5]] --set statusmarkers|aid-1 }} /w gm @{selected|token_name} casts Aid on @{target|1|token_name}, @{target|2|token_name} and @{target|3|token_name} granting [[5*?{Cast at what level?|Level 2,1|Level 3,2|Level 4,3|Level 5,4}-5]] additional hit points. Again, sometimes, this all works beautifully.  And other times, the spell goes off, targets are selected, but the hp change and status icons are not applied. 
1624035772

Edited 1624035815
There's a bug that sometimes appears when there are multiple lines of code with an API command where some of the lines just get 'dropped'.  That might be what's happening. I'm not sure if your macro is an exact cut-and-paste, but I see a couple issues: %{Elran|repeating_spell-2_-MZ2LiZRx77yY1iN5fEJ_spell} !token-mod {{ --ids @{target|1|token_id} @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set bar1_value|+[[5*?{Cast at what level?|Level 2,1|Level 3,2|Level 4,3|Level 5,4} -5 ]] --set statusmarkers|aid-1 }} /w gm @{selected|token_name} casts Aid on @{ target|1| token_name}, @{ target|1| token_name} and @{ target|1| token_name}. 1. You have target|1 listed twice in the ids section... I'm not sure if that will cause issues for TokenMod or not, but it's possible. 2. Then in the GM whisper at the end you have target|1 listed all three times instead of target|1 target|2 and target|3. 3. Lastly, it looks like your query for the amount to change the bar1_value will add 0hp at level 2, 5 hp at level 3, 10 hp at level 4, and 15hp at level 5.  Assuming you're playing D&D 5th edition and not using a homebrew version of Aid, those values are wrong. It looks like you adjusted the spell level value but kept the -5 modifier, so you should use one of these two: --set bar1_value|+[[5*?{Cast at what level?|2|3|4|5}-5]] --set bar1_value|+[[5*?{Cast at what level?|Level 2,1|Level 3,2|Level 4,3|Level 5,4}]] If the macro is working strangely, you could also try reordering the three commands to see if it makes a difference, so your final output might be something like this: /w gm @{selected|token_name} casts Aid on @{target|1|token_name}, @{target|2|token_name} and @{target|3|token_name}. !token-mod {{ --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set bar1_value|+[[5*?{Cast at what level?|Level 2,1|Level 3,2|Level 4,3|Level 5,4}]] --set statusmarkers|aid-1 }} %{Elran|repeating_spell-2_-MZ2LiZRx77yY1iN5fEJ_spell}
Thanks Jarren.  I was updating it as you posted your reply.  I did see some of those errors, but not the duplicate Target 1 in the ID.  Maybe that was it?  But my current macro looks like this and it worked 5 times in a row, so thanks for helping to get it working! %{Elran|repeating_spell-2_-MZ2LiZRx77yY1iN5fEJ_spell} !token-mod {{ --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set bar1_value|+[[5*?{Cast at what level?}-5]] --set bar1_max|+[[5*?{Cast at what level?}-5]] --set statusmarkers|aid-1 }} /w gm @{selected|token_name} casts Aid on @{target|1|token_name}, @{target|2|token_name} and @{target|3|token_name} granting [[5*?{Cast at what level?}-5]] additional hit points.
1624046898
The Aaron
Roll20 Production Team
API Scripter
Duplicate ids won't be a problem for TokenMod.  Changing the order is more likely what is helping.