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 an IF command or equivalent

In combat, our Hit Locations are 1 through 10, where 1 = head, 2,3,4 = torso, 5 = rightArm, 6 = leftArm, 7,8 = rightLeg, and 9,10 = leftLeg. My players have asked if the display can include the location in text as well as the number. Eg: hit location: 6 leftArm. I don't see a way to do this. Is it possible, and if so, how?
1706317072
Gauss
Forum Champion
Hi WynSnow,  You can do that most easily with a RollableTable, if there is no modifier. Alternately you can do it with a Mod (API Script) if there is a modifier.  Could you provide more information about what you are rolling?
Sure. Here's the code I'm currently using -- pretty sure it's as a token action. So [character] is rolling Damage [roll result] in Location [roll result]. The weapon is a Vz101. Damage is 4d6+1. Location is a straight 1d10. <div class = "boxRoll" > <button type = "roll" name = "roll_pistolHeavy" value = "&{template:custom} {{title=@{character_name} is rolling}} {{subtitle=Damage}} {{damage=?{Which|Vz101, [[4d6+1]] [Vz101]} }} &{template:custom} {{title=@{character_name} is rolling}} {{subtitle=Location}} {{location=[[1d10]]}}" ></button> Weapon </div>
The result shows up in the custom template in the chat window.
1706326579
Gauss
Forum Champion
For location's [[1d10]] I'd replace that with a Rollable table .  Note: there are other options, such as if you create your own character sheet, or via a Mod (API Script), but both are above my skill level. If you are interested in those options I'd post in the Character sheet forum (for character sheet coding) or the Mods (API scripts) forum for a Mod. 
1706378021

Edited 1706378066
GiGs
Pro
Sheet Author
API Scripter
There are only three ways to this: creating a Mod script edit the character sheet code, to use a Rollable table as Gauss suggests. If you want to use the result in other calculations (like, say, head hits do x2 damage, and limbs do x.5), you'll need a Mod Script or edit the character sheet. A Rollable table won't work - that method is only if you want to display the location and do nothing with it. The basic dice system of Roll20 does not allow or cope with IF statements.
Thank you Gauss and GiGs.  Let me see if I understand how to build the table. I would name the table Location . For the name of the New Item , I would put something like 1 Head , and weight of 1 . Then do the same for New Items of 2, 3, 4, 5, 6, 7, 8, 9 and 10? Then in my macro, I would replace [[1d10]] with [[1t[Location]]] . Is this correct? If so, that's pretty awesome. ( Almost as awesome  as having IF commands.) LOL. BTW, I do have custom character sheets. I had to build one that used Cyberpunk stats and skills.
1706465208

Edited 1706465449
GiGs
Pro
Sheet Author
API Scripter
That is correct, but you don't have to use the name 1 Head , you can just use Head . The weight column handles how common the item is. Based on the roll you said earlier, youd have Name    Weight Head     1 Torso     3 Right Arm 1 Left Arm 1 Right Leg 2 Left Leg 2 Note that a rollable table can't cope with modifiers at all, but as long as your table isn't modifed, this approach is fine. (If you want to show the hit roll, setting them all to a weight 1 and having 10 entries works too.)
1706465331

Edited 1706465463
GiGs
Pro
Sheet Author
API Scripter
If you're using custom character sheets, you can replace this table with a rolltemplate or custom roll parsing (and handle modifiers!), but it's not as straight forward, so if this works, great.
1706466078

Edited 1706466106
Gauss
Forum Champion
GiGs said: That is correct, but you don't have to use the name 1 Head , you can just use Head . The weight column handles how common the item is. Based on the roll you said earlier, youd have Name    Weight Head     1 Torso     3 Right Arm 1 Left Arm 1 Right Leg 2 Left Leg 2 Note that a rollable table can't cope with modifiers at all, but as long as your table isn't modifed, this approach is fine. (If you want to show the hit roll, setting them all to a weight 1 and having 10 entries works too.) GiGs, in the original post WynSnow stated that the players wanted the number and the name, hence "1 Head". 
1706466830
GiGs
Pro
Sheet Author
API Scripter
Gauss said: GiGs, in the original post WynSnow stated that the players wanted the number and the name, hence "1 Head". I realised that only after writing most of my post, hence the way I ended it :)
Thank you Gauss and GiGs! While I suppose we don't really need the number rolled, including it is icing on the cake. Since these are token actions, I don't need to try to decipher what you said about character sheets. And yes, using the rollable table should work just great! Thanks again!
There is a Mod Script called ScriptCards that supports conditionals (If, then, else statements) and much more.  As a pro users, you have access to it.
Thanks Will M. If I need something more complex than this Rollable Table, I will look into it. GiGs and Gauss, it turns out that I cannot do 1 Head , because then it just reports 1 . But if I do Head 1, that works. Yay!  Thanks again!
Having the number rolled is important, because sometimes the Torso is under partial cover. So for example, a 4 might hit the cover, whereas a 2 or 3 hits the PC.
1706548043
GiGs
Pro
Sheet Author
API Scripter
In that case, try (1) Head , if you want the number first
Hi GiGs, Nah, doesn't matter if number comes first or last as long as it's there -- but I thank you anyway. :-)