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

[HELP][TokenMod] Applying dammage rolls and armor reduction to bar1?

Hi everyone, I have started to script my games and someone said that the TokenMod could help me with what i wanted. Basically, what i want is to subtract a number given by me less the armor of the target, off the bar1 number. The script would be like : - "what's the dammage?" - i write the dammage (dammage rolls are made by a character sheet so i will need to be able to type the number rolled) - script subtracts armor of the target - script subtracts the final dammage number to the bar1 (which is my healthbar) Is that possible with TokenMod? And more importantly, how?
1446927783
Ziechael
Forum Champion
Sheet Author
API Scripter
This should do what you want: !token-mod --set bar1|[[ @{target|bar1} - [[ ?{Damage?|0} - @{target| armourattribute } ]] ]] --ids @{target|token_id} just change armourattibute with the name of the attribute for the targets armour :)
1446957740
The Aaron
Pro
API Scripter
Almost.  bar1 would set the current and max values of the bar.  You probably want: !token-mod --set bar1_value |[[ @{target|bar1} - [[ ?{Damage?|0} - @{target| armorattribute } ]] ]] --ids @{target|token_id} (and of course, change the armorattribute to whatever you use.
1446973100
Ziechael
Forum Champion
Sheet Author
API Scripter
I knew i'd missed something! Thanks Aaron :)
Thanks, works great! Now, if i want to specify if its a special damage or a physical damage ? I tried something like this : !token-mod --set bar1_value|[[ @{selected|bar1} - [[ ?{Damage?|0} - @{selected|?{Special ou physique?|Special,spedef_total|Physique,def_total}}} ]] ]] --ids @{selected|token_id} I replaced the "target" with "selected" (with "target" can i select more than one token?) and tried to do a query for "special or physical?" but i get: "No attribute was found for @{selected|?{Special ou physique?}"
Timer T. said: @{selected|?{Special ou physique?|Special,spedef_total|Physique,def_total}} Attributes cannot be expanded after Roll Queries are due to the order of operations . ?{Special ou physique?|Special,@{selected|spedef_total}|Physique,@{selected|def_total}}
Hmm Now it does nothing... ^^ The complete macro is : !token-mod --set bar1_value| [[ @{selected|bar1} - [[ ?{Damage?|0} - ?{Special ou physique? |Special, @{selected|spdef_total} | Physique,@{selected|def_total} } ]] ]] --ids @{selected|token_id} And when i activate it with a token selected, it doesn't do anything, even in the chat, even with an atrocious amount of damage.
1447033694
The Aaron
Pro
API Scripter
For testing, it's sometimes handy to leave the ! off the front and see what the command is after the variable are expanded. That should give a clue as to what is wrong. 
1447034111
The Aaron
Roll20 Production Team
API Scripter
Also, you can use multiple different target statements, you just need to give them individual names: @{target|The First|token_id} @{target|The Second|token_id} @{target|The Second|bar1|max} If you use the same name again, it uses the same target for picking the resulting attribute. Note that using a name in the @{target} is required if you want to access the max portion of an attribute &nbsp; &nbsp;see:&nbsp; <a href="https://wiki.roll20.net/Macros#Advanced_Usage" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage</a>
For testing, it's sometimes handy to leave the ! off the front and see what the command is after the variable are expanded. That should give a clue as to what is wrong. Ok, so i did some testing and here is the results : "Damage?" HP in bar1 HP in bar1 after armor result shown inline roll 0 44 44 15 0 44--15=44-15 5 44 44 15 0 44--10=44-10 20 44 44 15 39 44-5=44-5 100 44 44 15 -41 44-85=44-85 The chat looks like that: token-mod --set bar1_value| 0 --ids -K2XgZEaAvCL5pKhk8El token-mod --set bar1_value| 0 --ids -K2XgZEaAvCL5pKhk8El token-mod --set bar1_value| 39 --ids -K2XgZEaAvCL5pKhk8El token-mod --set bar1_value| -41 --ids -K2XgZEaAvCL5pKhk8El Tested them all with the !, does nothing to the token. It seems more complicated than i thought, if the armor is higher than the damage, it subtract the rest of the armor to the HP.
1447077031
The Aaron
Pro
API Scripter
The problem is the space after the bar1_value| &nbsp; !token-mod --set bar1_value| 0 --ids -K2XgZEaAvCL5pKhk8El !token-mod --set bar1_value| 0 --ids -K2XgZEaAvCL5pKhk8El !token-mod --set bar1_value| 39 --ids -K2XgZEaAvCL5pKhk8El !token-mod --set bar1_value| -41 --ids -K2XgZEaAvCL5pKhk8El What you have is basically like saying: !token-mod --set bar1_value| --set 0| --ids -K2XgZEaAvCL5pKhk8El When it parses the command, it tries to set bar1_value to nothing (ignored, so no change), then tries to change 0 to nothing (0 is not a valid attribute of the token, so is ignored). Change your command to this: !token-mod --set bar1_value|[[ @{selected|bar1} - [[ ?{Damage?|0} - ?{Special ou physique? |Special, @{selected|spdef_total} | Physique,@{selected|def_total} } ]] ]] --ids @{selected|token_id}
1447077688

Edited 1447077975
Checked the API console output... Another script crashed, so it stopped all the other scripts... Not sure it was working before i installed the other script, will re-do all the testing tonight!
1447103265

Edited 1447104132
OK ! Did all the test and .... it appears im just an idiot to not have seen that the API crashed! ^^ Now it works but only when the damage are equal or higher than the armor :/ It apply 0 to bar1 in the case the damage are strickly lower than the armor: &nbsp;token-mod --set bar1_value|0&nbsp;--ids -K2i1Lwtt6ixznF51en7 with the inline roll being "71--1=71-1" with 71 being the health of the token and 1 being the rest of the armor (23 damage versus 24 armor) I guess having a double negative in the formula messed it up a bit. &nbsp;Does adding a minimum so it doesn't go to the negative, would&nbsp;work ? I am trying to find the macro function for setting minimum or maximum but i don't find anything on it.
1447116560
The Aaron
Pro
API Scripter
Just put the damage in as a positive number, it change your - to a + in the formula. 1-(-1) = 2 is just how math works. :) You can use the keep syntax for rolls to get the higher or lower of two values: [[ {1d4,3d1}kh1 ]] is 3 or 4 [[ {[[@{attribute}-@{other_attribute}]], 0}kh1 ]] is a minimum of 0 Groups in { } must be either all dice expressions (first line above) or all flat numbers (second line above) or you'll get an error.&nbsp;
1447144129

Edited 1447144606
Aaaaaah !! GOT IT! Thanks for the command, it works now! : token-mod --set bar1_value|[[{[[ @{selected|bar1} - {[[ ?{Damage?|0} - ?{Special ou physique? |Special, @{selected|spdef_total} | Physique,@{selected|def_total} } ]],0}kh1 ]],0}kh1]] --ids @{selected|token_id} I placed a minimum of 0 for the calcul of the damage versus the armor to not have negative and, also placed a minimum of 0 to the total damage to have bar1 stopping at 0 and not go to a negative. Will play around with it a little to see if its alright but it seems good now ^^ BIG thanks to everyone!!
1447167453
The Aaron
Pro
API Scripter
No problem! &nbsp;=D