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

Macro for healing a target using a repeating resource and modbattr

Hi all,  So i Have this Macro working perfectly :  !&{template:npcaction} {{rname=Soins du Marteau de Guerre}} {&if ([ResourceCheck]@{Galy|repeating_resource_$2_resource_left} > 0)}!modbattr --name Galy --silent --evaluate --repeating_resource_$2_resource_left|-1!!!{&end} {{description={&if ResourceCheck}Galy utilise le pouvoir du Marteau de Guerre et offre [[1d8+1]] PV{&else}Galy ne peut plus utiliser le pouvoir du Marteau de Guerre avant un repos long.{&end}}}{&simple} Now i would like to have Galy select a target and auto apply the result of the dice (1d8+1) to the hp of the target (without exceeding max of course...) I know there some possibilities using some reentrants entries but i haven't fully found the solution so far. My game is in 2h30 and i'd love to have it working this way if anyone has the right syntax for this ??? Thx
1672250935
GiGs
Pro
Sheet Author
API Scripter
You cant modify a sheet with macros. They can only read values, not write changes to characters. It looks like you have a script (chatSetAttr?) embedded in your macro. That can make changes to a character, but you would be best testing those changes with a separate macro first that only makes the changes you want. Once that is working, you can include it in your macro.
1672253249

Edited 1672253296
I have a "lay on hads macro using modbattr and token mod, too...  All i want to do is have the user target a token, roll 1d8+1 and set the target's bar 1 + that value, but have this function inside my check resource sequence i can't seem to be able to make both only one efficient macro. !?{Nombre de points de vie a donner|@{selected|other_resource}} !token-mod --ids @{target|Qui guérir|token_id} --set bar1_value|+[[{?{Nombre de points de vie a donner},[[@{target|Qui guérir|hp|max}-@{target|Qui guérir|hp}]]}kl1]] !modattr --silent --name @{selected|token_name} --other_resource|-[[{?{Nombre de points de vie a donner},[[@{target|Qui guérir|hp|max}-@{target|Qui guérir|hp}]]}kl1]] &{template:atkdmg} {{desc=Vous pouvez également dépenser 5 points de vie de votre réserve pour guérir la cible d'une maladie ou neutraliser un poison qui l'affecte. Vous avez utilisé [[{?{Nombre de points de vie a donner},[[@{target|Qui guérir|hp|max}-@{target|Qui guérir|hp}]]}kl1]] points.}} {{charname=@{selected|token_name}}} {{normal=1}} {{mod=sur ***@{target|Qui guérir|token_name}***}} {{rname=IMPOSITION DES MAINS }} {{attack=1}} {{r1=[[{?{Nombre de points de vie a donner},[[@{target|Qui guérir|hp|max}-@{target|Qui guérir|hp}]]}kl1]]}} {{dmg1flag=1}} {{damage=1}} {{dmg1=[[@{selected|other_resource}-[[{?{Nombre de points de vie a donner},[[@{target|Qui guérir|hp|max}-@{target|Qui guérir|hp}]]}kl1]]]]}}{{dmg1type=points restants}}
1672257797
timmaugh
Pro
API Scripter
This is an interesting edge case... Your initial message will have selected tokens, and they would persist if you wrote the command to simply continue through the stack of mod scripts (imagine writing the command line as a !modbattr call, with a separate meta operation generating a templated output for the message). In that case, it acts like a single message going through the meta loop and then into the mod stack. For the way you have it constructed, your initial message is stopped after the meta loop (the {&simple} stops the message from continuing to the mod stack). This IS what you want for the template to hit the chat, however, that means that the meta loop generates a NEW message at that point, sending the finalized template to the chat. Since that is a message initiated by a mod script, you have no selected tokens. I think the fix is to include the proper character-selection syntax for ChatSetAttr in the modbattr portion of the command line. That is, typically ChatSetAttr works on (I think) the character attached to the first selected token (of which there is none with a mod-generated message). I believe that is the default behavior for CSA. However, you can explicitly give it a character ID. I think your final syntax would be: !&{template:npcaction} {{rname=Soins du Marteau de Guerre}} {&if ([ResourceCheck]@{Galy|repeating_resource_$2_resource_left} > 0)}!modbattr --name Galy --silent --charid @{selected|character_id} --evaluate --repeating_resource_$2_resource_left|-1!!!{&end} {{description={&if ResourceCheck}Galy utilise le pouvoir du Marteau de Guerre et offre [[1d8+1]] PV{&else}Galy ne peut plus utiliser le pouvoir du Marteau de Guerre avant un repos long.{&end}}}{&simple}
1672257882
timmaugh
Pro
API Scripter
Or, since you used the word "target", replace @{selected|character_id} with @{target|Target|character_id}
That doesn't work, as it is asking the target correctly but is trying to find a repeating resource in the target sheet that doesn't exist. Galy should ask who is going to be receiving the healing (target), launch the dice (1d8+1) and change the bar1_value of the target by this result (without exceeding the max of course), and have her own repeating resource counted down I think the solutions resides in the token mod command in the second macro (the lay on hands one) but don't realy know how to mix this token mod command with the rest of the macro (reusing the dice result for the chat output and the target destination)
1672285596
timmaugh
Pro
API Scripter
If you want to combine them into a single command (because they all rely on the same die-rolls), you can throw one in a Plugger statement. Or, hell, both of them. !&{template:atkdmg}[[{?{Nombre de points de vie a donner},[[@{target|Qui guérir|hp|max}-@{target|Qui guérir|hp}]]}kl1]] ?{Nombre de points de vie a donner|@{selected|other_resource}} {{desc=Vous pouvez également dépenser 5 points de vie de votre réserve pour guérir la cible d'une maladie ou neutraliser un poison qui l'affecte.  Vous avez utilisé $[[1]].value  points.}} {{charname=@{selected|token_name}}} {{normal=1}} {{mod=sur ***@{target|Qui guérir|token_name}***}} {{rname=IMPOSITION DES MAINS }} {{attack=1}} {{r1=$[[1]]}} {{dmg1flag=1}} {{damage=1}} {{dmg1=[\][\]@{selected|other_resource}-$[[1]] \]\]}}{{dmg1type=points restants}}{&simple} {&eval} !token-mod --ids @{target|Qui guérir|token_id} --set bar1_value|+$[[1]].value{&/eval}{&eval} !modattr --silent --name @{selected|token_name} --other_resource|-$[[1]].value {&\eval} Air-coded, so normal caveats apply. If I accurately read what you had, you had a roll that you were using over and over. You used it in each of the templated output, the chatsetattr command, and the token-mod command. I put it in the main message (I used the template as the main containing message), and then extracted the value in the other places it was referenced (by way of using the .value feature of ZeroFrame). In what I built, both the TokenMod and the ChatSetAttr command are in their own Plugger tags, which will dispatch them as separate messages (that's why we extract the roll value, first... because otherwise the roll data won't be in the secondary messages). It looks as though you have adequately referenced the token and/or character for the outbound messages to work in TM and CSA (since those are mod-messages, now). Last... I'm a little confused whether this was the macro you wanted fixed, or something else...? If it's not this one, post back and I'll give the same treatment to another set of macros.
True, I haven't been very clear on what I 'm looking for.  The first macro I posted is what i' d like to be appenfed.  I have the first macro where galy is using a resource to heal someone by 1d8+1. It checks the availability of the resource, and if available reduces this resource by 1.  In the description there's a roll to tell how much hit points are healed.  What I'd like is, if possible, to have galy determine who is gonna be healed by targeting the token, and have the result of the dice directly applied to the token bar1(and thus in his character sheet)  The second macro does that with lay on hands (and this one works perfectly like that). I just posted the second macro because it does apply the chosen number of hit points to a target.  The token mod command in that second macro actually defines the number of hit points, and the target, that are reused after in the mofbattr part. I'd like to do the same for the second macro : Roll the 1d8+1 thing, define the target, and reuse these entries in the rest of the macro to aplly these hit points to the defined target, and get all that inside the checking resource macro.  I'll try to fiddle a little bit more with this, but I can't seem to find the right solution so far.  Thx for your research though. 
i'm advancing slowly :  !token-mod --ids @{target|Qui guérir|token_id} !&{template:npcaction} {{rname=Soins du Marteau de Guerre}} {&if ([ResourceCheck]@{Galy|repeating_resource_$2_resource_left} > 0)}!modbattr --name Galy --silent --evaluate --repeating_resource_$2_resource_left|-1!!!{&end} {{description={&if ResourceCheck}Galy utilise le pouvoir du Marteau de Guerre et offre [[1d8+1]] PV à @{target|Qui guérir|token_name}{&else}Galy ne peut plus utiliser le pouvoir du Marteau de Guerre avant un repos long.{&end}}}{&simple} this identifies correctly the target (his name is repeated in the description) now i need to identify the roll so i can reuse it in a token-mod call to change the bar... it would be easy if i was asking for a query (something like ?{how many HP?|[[1d8+1]]} ), so i can recall the ?{how many HP?} later, but that shouldn't be a query but just a roll, and i don't know how to reference that....
1672327249
timmaugh
Pro
API Scripter
The reason your other command series works (the one that I rejiggered into a single command) is because you rebuilt your inline roll every time. That is, there was no randomness to it, so every time you built it it would be the same. With an actual roll (like what you're looking to do in the problematic macro), you have to preserve that value. Roll values don't persist between separate messages (so it won't last between your token-mod command and your template command), but you can combine all of this into a single command and extract the value as needed. !{&eval}token-mod --ids @{target|Qui guérir|token_id} --set bar1_value|+[[1d8+1]].value!{&/eval} &{template:npcaction} {{rname=Soins du Marteau de Guerre}} {&if ([ResourceCheck]@{Galy|repeating_resource_$2_resource_left} > 0)}!modbattr --name Galy --silent  --evaluate --repeating_resource_$2_resource_left|-1!!!{&end} {{description={&if ResourceCheck}Galy utilise le pouvoir du Marteau de Guerre et offre $[[0]].value PV à @{target|Qui guérir|token_name}{&else}Galy ne peut plus utiliser le pouvoir du Marteau de Guerre avant un repos long.{&end}}}{&simple} That puts the TokenMod command in a plugger block to send it separately. The inline roll in that portion will be executed (and the data stored) in the top level/original message, so when we issue the TokenMod command, we have to have already extracted the value from the roll (with .value ). Finally, the '+' of the setting operation and the '!' at the end of the setting syntax tell TokenMod to add the roll value without going over the max for bar1. I'm not sure if you need the second .value (in the ChatSetAttr portion of the command line), but probably. With this going through the ZeroFrame loop first, you aren't going to send the CSA command until after ZeroFrame has squashed the original message (using {&simple} ) and re-issued one that will hit the chat. A couple of things to think about: 1) There had been a bug with TokenMod in the version that checked whether the bar was linked to a character sheet or not (if it was linked, TM would set the attribute instead of modifying the bar value). I'm not sure if Aaron has gotten the time to correct that bug, so you might have to make sure you're using a previous version of TM (and I apologize for not knowing what that version is). If, when you back down the version, you need to differentiate whether this is a character-token (with a linked bar1) or a mook (with an unlinked bar1), you can use an {&if} block to read the bar1_link: {&if '@(@{target| Qui guérir|token_id}.bar1_link)' = ''} ... no link, use token-mod syntax ... {&else} ...linked, so use ChatSetAttr syntax ... {&end} (quotation marks/apostrophes provide markers for the parser in case nothing is there, so must be included) All of that can go in the EVAL block so long as the roll value is extracted using the .value syntax. It doesn't matter if APILogic runs before Plugger (it typically doesn't). It will either run in the original message (simplifying what Plugger is sending down to either just the TM syntax or just the CSA syntax), or it will run in the Plugger outbound message (removing the extraneous portion there). Since you are using the targeting statement to get the token id, that will populate immediately. 2) Your template currently reports the amount of the rolled healing, but that might have been more than could be used (since you're capping at the max of the bar). If you wanted to, you could report the total rolled in this fashion (as currently constructed), but then offer a "how much could be used" roll that would do the math. You could put that in a nested IF block in your report. Here is the new bit: {&if $[[0]].value  >  [[ @{target| Qui guérir|bar1|max}- @{target| Qui guérir|bar1}]].value },  dont seulement $[[1]].value  ont pu être appliqués{&end} And then here is that embedded in your current IF block: {{description={&if ResourceCheck}Galy utilise le pouvoir du Marteau de Guerre et offre $[[0]].value PV à @{target|Qui guérir|token_name} {&if $[[0]].value  >  [[ @{target| Qui guérir|bar1|max}- @{target| Qui guérir|bar1}]].value },  dont seulement $[[1]].value  ont pu être appliqués{&end} {&else}Galy ne peut plus utiliser le pouvoir du Marteau de Guerre avant un repos long.{&end}}}
Perfect and perfectly clear as usual.  Always a pleasure to have an answer and understand it !! lol Thanks a lot timmaugh.  everyday i'm walking a step forward to manage my issues myself... or at least get close to the goal...  Happy holidays to all !