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

Is there no way to combine script calls in one macro?

I'm trying to jury-rig a hit dice helper macro, since the existing script breaks all my stuff. I have both parts of the macro running fine in isolation. One uses tokenmod to heal the character based on HD and Con mod. The other uses ChatSetAttr to decrement the hit dice count on the character sheet. But I can't run them from a single macro. When I do, only the tokenmod part (being first) triggers. Am I missing something, or is this simply an inherent limitation of the macro format?
1587952720
The Aaron
Roll20 Production Team
API Scripter
Can you post the multiline macro with both commands?   There are two things to be aware of when using multiple API commands in a macro or ability (or multiple lines in chat): Attribute references are expanded in all lines before any lines are executed. This means if you have something like @{selected|bar1} passed to both commands, but the first changes the value, that change will not be reflected in the arguments to the script.  Using @{target|...} will prevent API Commands from being passed the list of selected tokens implicitly. If one of your scripts operates on selected tokens, you either need the script to take arguments for a selected (or other @{target|...} calls), or not use any @{target|...} calls. 
Here's the macro: !token-mod --set bar1_value|[[{@{selected|bar1|max},[[@{selected|bar1}+[[1d@{selected|hitdietype}+[[@{selected|constitution_bonus}]]]]]]}kl1]] --report all|"/em {name} heals {bar1_value:change} points." !modbattr --sel --hit_dice|-1 --fb-public --fb-from @{selected|character_name} --fb-header Spend Hit Dice --fb-content You have just drawn on your inner fortitude to regain health. You have **_CUR0_ Hit Dice** remaining.
1587968415
The Aaron
Roll20 Production Team
API Scripter
Is  !modbattr  correct?  Seems like it should be  !modattr  but I'm not overly familiar with the script.
1587976752

Edited 1587977059
The !modbattr command ensures the values stay between 0 and the attribute's max. I have run into this issue a lot, even with very simple commands. I've found that adding lines with exclamation points can sometimes help. At least, the second macro is ignored less frequently this way, but it's still ignored sometimes. Idr where I learned about this method, but give this a try: !token-mod --set bar1_value|[[{@{selected|bar1|max},[[@{selected|bar1}+[[1d@{selected|hitdietype}+[[@{selected|constitution_bonus}]]]]]]}kl1]] --report all|"/em {name} heals {bar1_value:change} points." ! !modbattr --sel --hit_dice|-1 --fb-public --fb-from @{selected|character_name} --fb-header Spend Hit Dice --fb-content You have just drawn on your inner fortitude to regain health. You have **_CUR0_ Hit Dice** remaining !
There's been a few occasions where swapping the order got the macro working more often, too, so I suggest trying that if the above doesn't work. I'm very curious if anyone knows of a more effective method, though. I still have a handful of multi command macros that sometimes need to be clicked a second or third time to get both commands to fire.
Thank you both. @Persephone, I tried it with exclamation points, and then with the order reversed, but neither worked. Only the first script call worked (tokenmod initially, then ChatSetAttr when I put it first). I'm really at a loss. Calling each of them on their own works fine. I just can't do both within the same macro.
I thought I’d read something like this before. Is this of any use? <a href="https://app.roll20.net/forum/post/8302387/slug%7D#post-8303075" rel="nofollow">https://app.roll20.net/forum/post/8302387/slug%7D#post-8303075</a>
Patrick said: I thought I’d read something like this before. Is this of any use? <a href="https://app.roll20.net/forum/post/8302387/slug%7D#post-8303075" rel="nofollow">https://app.roll20.net/forum/post/8302387/slug%7D#post-8303075</a> Thanks, Patrick. I hadn't seen that. However, that thread is focused on a short rest and doesn't decrement hit dice #, as I'm trying to do here. Still useful to see it, though. I'll try combining two ChatSetAttr commands instead of using it and tokenmod. Maybe that will work.&nbsp;
Are you sure? &nbsp;I just read it again and the code discussed looked like it reduced hit die.
Patrick said: Are you sure? &nbsp;I just read it again and the code discussed looked like it reduced hit die. Yes, I think you're right, on second glance. But I don't really need help with that aspect. I can decrement HD just fine. The one in that thread is using a different script to reduce hit dice, as well.
Hmm. This second macro now works, but since it's using ChatSetAttr to reduce hit points, it's not turning off my bloodied status marker whenever the token goes back above half HP. Is there a way to get the marker turn off? !modbattr --sel --hp|+[[1d@{selected|hitdietype}+[[@{selected|constitution_bonus}]]]] !modbattr --sel --hit_dice|-1 --fb-public --fb-from @{selected|character_name} --fb-header HD Rem. --fb-content You have **_CUR0_ Hit Dice** remaining.
I use death tracker. &nbsp;I think it “listens” for hp changes. &nbsp;If I lower the hp of a token below half it marks them bloodied. &nbsp;If I raise the hp above half it goes away. &nbsp;It also marks NPC’s dead at 0 and PC’s unconscious.
Patrick said: I use death tracker. &nbsp;I think it “listens” for hp changes. &nbsp;If I lower the hp of a token below half it marks them bloodied. &nbsp;If I raise the hp above half it goes away. &nbsp;It also marks NPC’s dead at 0 and PC’s unconscious. I use an OnBloodiedAndDying script that TheAaron kindly wrote for me. It works fine in all other contexts. It's just this instance with ChatSetAttr that isn't working.
Update. Installed Death Tracker (modded to use my custom status markers for bloodied and dying), disabled the OnBloodiedAndDying snippet, and now my Hit Dice script works. Very strange. Here's the code in case anyone finds it useful: !token-mod --set bar1_value|[[{@{selected|bar1|max},[[@{selected|bar1}+[[1d@{selected|hitdietype}+[[@{selected|constitution_bonus}]]]]]]}kl1]] --report all|"/em {name} heals {bar1_value:change} points." !modbattr --sel --hit_dice|-1 --fb-public --fb-from @{selected|character_name} --fb-header Hit Dice Tracking --fb-content You have **_CUR0_ Hit Dice** remaining.