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

Creating a healing potion macro

hey, I'm doing a bit of testing with the macros and I've found some pretty good options, the problem is that I'm running into problems that are probably caused by the syntax (or impossible to do).  so this is what happened,   i try to make an easy way to for my player to use potions so i write this macro :  ?{Potion of |Healing,/roll 2d4+2| Greater Healing,/roll 4d4+4| Superior Healing,/roll 8d4+8| Supreme Healing,/roll 10d4+20} its nice an "print" the result in the chat box, then they add it to their character sheet or their linked token so I thought it might be possible to go a step further :  !token-mod --set bar1_value|?{Potion of|Healing,+[[2d4+2]]|Greater Healing,+[[4d4+4]]|Superior Healing,+[[8d4+8]]|Supreme Healing,+[[10d4+20]]} so now they they have a button in their token action that let them heal it. BUT we can't see the result in the chat so I tried to put the two into one macro  &{template:default} !token-mod --set bar1_value|?{Potion of|Healing,+[[2d4+2]]|Greater Healing,+[[4d4+4]]|Superior Healing,+[[8d4+8]]|Supreme Healing,+[[10d4+20]]} {{name=Heal}} = {{$[[0]]}} but I can't get it to work  thank you in advance for your help 
1748617579

Edited 1748619681
timmaugh
Forum Champion
API Scripter
In your other thread (about the NameGen script), I mention that there are other tricks the MetascriptToolbox offers than can help with both using a value and reporting it to the user. This is another case where it can help for nearly the same thing. So, as in the other thread, make sure you have the MetascriptToolbox installed. Then change your command line to something like (untested): !{{   (^){^&template:default} ({)name=Healing(}) ({)=@{selected|character_name} gains  ?{Potion of|Healing,[[2d4+2]]|Greater Healing,[[4d4+4]]|Superior Healing,[[8d4+8]]|Supreme Healing,[[10d4+20]]} points of healing.(})   !token-mod --set bar1_value|+$[[0]] }} If you want to state in the template what kind of potion was consumed, that takes a little more work, but is achievable: !{{   {&global ([HealingRoll][[2d4+2]]) ([Greater HealingRoll] [[4d4+4]] ) ([Superior HealingRoll][[8d4+8]]) ([Supreme HealingRoll][[10d4+20]])  ([HealingRoll][[2d4+2]])   }   (^){^&template:default} ({)name=Healing(}) ({)=@{selected|character_name} takes a potion of ?{ Potion of|Healing|Greater Healing|Superior Healing|Supreme Healing} and regains ?{Potion of}Roll points of healing.(})   !token-mod --set bar1_value|+?{Potion of}Roll }} Here are examples of 2 runs of that output:
thanks you,  the first one work really great  but the second one make some problem when i use a query  but thanks a lot, i'll use the first one 
1748619769
timmaugh
Forum Champion
API Scripter
Hmm... I think I forgot the "+" in the TokenMod command, so instead of adding the healing points to the token it was *replacing* the points. I have corrected that, above, but here is the same command again. !{{   {&global ([HealingRoll][[2d4+2]]) ([Greater HealingRoll][[4d4+4]]) ([Superior HealingRoll][[8d4+8]]) ([Supreme HealingRoll][[10d4+20]]) ([HealingRoll][[2d4+2]]) }   (^){^&template:default} ({)name=Healing(}) ({)=@{selected|character_name} takes a potion of ?{Potion of|Healing|Greater Healing|Superior Healing|Supreme Healing} and regains ?{Potion of}Roll points of healing.(})   !token-mod --set bar1_value|+?{Potion of}Roll }} If that isn't the problem you were running into and you can post back with more information I can try to get to the bottom of what might be going on.
it still doesn't work,  the 1st healing potion works well, but it seems to be the only one. the other potion inserts the name of the potion in the bar, not the roll.  and the roll in the chat is wrong (2d4+2 instead of 4d4+2).
1748656599
timmaugh
Forum Champion
API Scripter
OK, found the problem. All of the global variables are a simple text replacement... so if one of them is looking for "HealingRoll" while another of them is looking for "Greater HealingRoll", that is going to cause a problem if I let the former (less specific) search happen first. In other words, if the line says: Commoner takes a potion of Greater Healing and regains Greater HealingRoll points of healing. ...and we search for "HealingRoll"... we'll find it. We'll find it, replace it with the roll for HealingRoll (that's why it's the wrong roll), and we'll leave the word "Greater" behind. If, instead, we search for "HealingRoll" last... giving all of the other potion rolls a chance to see if they need to do any replacement, then "Greater HealingRoll" will be found, all of it will be replaced, and it will be replaced with the correct roll. Basically, I meant to MOVE the HealingRoll global variable to the end of the global variables, and I just duplicated it and left it at the head of the order. TL;DR *This* command now works perfectly: !{{   {&global ([Greater HealingRoll][[4d4+4]]) ([Superior HealingRoll][[8d4+8]]) ([Supreme HealingRoll][[10d4+20]]) ([HealingRoll][[2d4+2]]) }   (^){^&template:default} ({)name=Healing(}) ({)=@{selected|character_name} takes a potion of ?{Potion of|Healing|Greater Healing|Superior Healing|Supreme Healing} and regains ?{Potion of}Roll points of healing.(})   !token-mod --set bar1_value|+?{Potion of}Roll }} Question... Do you mean to let the bar surpass its max value? If you don't, you can append a "!" to the end of the value to force it to be bounded between 0 and the max value of the bar: !token-mod --set bar1_value|+?{Potion of}Roll! If you do decide to go that way, then you might want to consider reporting a different number in the template. It might be confusing to say that someone gained 30pts of healing when their bar would only let them apply 14. Here's an option that uses some IF/THEN logic blocks to shape the message to match what results from the potion: !{{   {&global ([Greater HealingRoll][[4d4+4]]) ([Superior HealingRoll][[8d4+8]]) ([Supreme HealingRoll][[10d4+20]]) ([HealingRoll][[2d4+2]]) }   (^){^&template:default} ({)name=Healing(}) ({)=@{selected|character_name} takes a potion of ?{Potion of|Healing|Greater Healing|Superior Healing|Supreme Healing} {&if ?{Potion of}Roll >= [[@{selected|bar1|max}-@{selected|bar1}]]} which offers ?{Potion of}Roll points of healing, {&if ?{Potion of}Roll = [[@{selected|bar1|max}-@{selected|bar1}]]}exactly what{&else}more than the [[@{selected|bar1|max}-@{selected|bar1}]] points{&end} they need to restore them to full health.{&else}and regains ?{Potion of}Roll points of healing.{&end}(})   !token-mod --set bar1_value|+?{Potion of}Roll! }} Here is an example where Ruby took a potion of Greater Healing and regained healing that did not max out her bar 1: ...and another option where she took a potion of Superior Healing, which offered more points than she could utilize (since we bounded the TokenMod adjustment to the max value of bar1):
First of all, thank you very much for your help. Both scripts work very well, and the little feature you added is really great because it saves time.  I hope my players will like it and that it will help other people who come across it.