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

Can i use IF ELSE in my rolls?

First of all, sorry for the english guys, i'm brasiliam. So, i want to know if i can use if else in my rolls.    I'm doing a pokémon sessions and this will help me a lot. I not good programming, but i can understand something. Now i'm using this roll for a tackle: " &{template:default} {{name=Investida Scorbunny}} {{Acerto = 100%}} {{Acerto Seguido= 100%}} {{Investida= [[[floor(1d10/2) + 4 +@{Ataque}]]]}} {{Tipo = Normal}} {{Descrição = Golpe Únicamente de Dano}}". But every crit or something that changes the attack i'm making manually and mentally. What i want to do is use if else to change the final result like: if (rolldice == 10) { result final*1.5 } else { result final only }. Is there a possibility to do that? I can use API's. Thank you very much for the atention. 
1726451714
timmaugh
Pro
API Scripter
Hi, Michael B....  yes, since you can use scripts, you can do what you want. There's probably a way to do this with ScriptCards, and maybe Jarren can pipe in and offer a suggestion as to how. The solution I will show uses the MetaScript Toolbox (available in the 1-click). As I understand what you're trying to do, this is your roll equation: floor(1d10/2) + 4 + @{Ataque} If the 1d10 in that equation turns out to be a 10, you want that whole amount to be multiplied by 1.5. {&r}(floor([[1d10]]/2) + 4 + @{Ataque}) {&if $[[0]] = 10}* 1.5{&end} {&/r} That produces a roll where the x1.5 multiplier is only included if the d10 turns out to be 10. To get there, I had to wrap the d10 in its own roll brackets so I could refer to them later, and I had to defer the outer/final roll one time to allow the conditional to process out. You can see this bit of the equation included in an example where I rolled a 10: Your final/full command would look like this, then: !&{template:default} {{name=Investida Scorbunny}} {{Acerto = 100%}} {{Acerto Seguido= 100%}} {{Investida= {&r}(floor([[1d10]]/2) + 4 + @{Ataque}) {&if $[[0]] = 10}* 1.5{&end} {&/r} }} {{Tipo = Normal}} {{Descrição = Golpe Únicamente de Dano}} {&simple}
This particular logic can be done without any fancy tools with a roll expression: [[floor({0d0+[[1d10=10]]*1.5*[[5 + 4 + @{Ataque} ]],1d9/2 + 4 + @{Ataque} }kh1)]] If you would roll a 10, the simple equation of 1.5*(10/2 +  4 + @{Ataque} is used. if the initial roll is not 10, a 1d9/2 + 4 + @{Ataque} equation is used instead (since it was already resolved that you did not roll a 10, a d9 is used instead).
timmaugh said: Hi, Michael B....  yes, since you can use scripts, you can do what you want. There's probably a way to do this with ScriptCards, and maybe Jarren can pipe in and offer a suggestion as to how. The solution I will show uses the MetaScript Toolbox (available in the 1-click). As I understand what you're trying to do, this is your roll equation: floor(1d10/2) + 4 + @{Ataque} If the 1d10 in that equation turns out to be a 10, you want that whole amount to be multiplied by 1.5. {&r}(floor([[1d10]]/2) + 4 + @{Ataque}) {&if $[[0]] = 10}* 1.5{&end} {&/r} That produces a roll where the x1.5 multiplier is only included if the d10 turns out to be 10. To get there, I had to wrap the d10 in its own roll brackets so I could refer to them later, and I had to defer the outer/final roll one time to allow the conditional to process out. You can see this bit of the equation included in an example where I rolled a 10: Your final/full command would look like this, then: !&{template:default} {{name=Investida Scorbunny}} {{Acerto = 100%}} {{Acerto Seguido= 100%}} {{Investida= {&r}(floor([[1d10]]/2) + 4 + @{Ataque}) {&if $[[0]] = 10}* 1.5{&end} {&/r} }} {{Tipo = Normal}} {{Descrição = Golpe Únicamente de Dano}} {&simple} Thank you so much, it work but unfortunately the dice animation did not work, and i like to see this animation. I had a way to do this? Thank you for yout time <3
Tuo said: This particular logic can be done without any fancy tools with a roll expression: [[floor({0d0+[[1d10=10]]*1.5*[[5 + 4 + @{Ataque} ]],1d9/2 + 4 + @{Ataque} }kh1)]] If you would roll a 10, the simple equation of 1.5*(10/2 +  4 + @{Ataque} is used. if the initial roll is not 10, a 1d9/2 + 4 + @{Ataque} equation is used instead (since it was already resolved that you did not roll a 10, a d9 is used instead). I tried this but its not working :( thank you so much for the attetion and answer <3
timmaugh said: yes, since you can use scripts, you can do what you want. There's probably a way to do this with ScriptCards, and maybe Jarren can pipe in and offer a suggestion as to how. Just saw this haha - I’m not a Scriptcards user; I think you’re confusing me with Joshua N.  :) Michael B. said: timmaugh said: Thank you so much, it work but unfortunately the dice animation did not work, and i like to see this animation. I had a way to do this? Thank you for yout time <3 Unfortunately the dice animation only displays for native Roll20 rolls using the Quantum Roll generator.  The final dice expression that was made there doesn’t include a dice roll anymore because it was hidden within inline roll brackets. I’m not sure if it would be possible to hide the entire calculation and reuse the roll for display purposes to still show the 3D dice. 
1726513154

Edited 1726513167
Michael B. said: Tuo said: This particular logic can be done without any fancy tools with a roll expression: [[floor({0d0+[[1d10=10]]*1.5*[[5 + 4 + @{Ataque} ]],1d9/2 + 4 + @{Ataque} }kh1)]] If you would roll a 10, the simple equation of 1.5*(10/2 +  4 + @{Ataque} is used. if the initial roll is not 10, a 1d9/2 + 4 + @{Ataque} equation is used instead (since it was already resolved that you did not roll a 10, a d9 is used instead). I tried this but its not working :( thank you so much for the attetion and answer <3 That is very strange, because as long as @{Ataque} resolves to a number, it works. So either there's an issue in your template that you added it to, or there's an issue with your attribute. Without seeing either, I can't say where exactly the error is.
Tuo said: Michael B. said: Tuo said: This particular logic can be done without any fancy tools with a roll expression: [[floor({0d0+[[1d10=10]]*1.5*[[5 + 4 + @{Ataque} ]],1d9/2 + 4 + @{Ataque} }kh1)]] If you would roll a 10, the simple equation of 1.5*(10/2 +  4 + @{Ataque} is used. if the initial roll is not 10, a 1d9/2 + 4 + @{Ataque} equation is used instead (since it was already resolved that you did not roll a 10, a d9 is used instead). I tried this but its not working :( thank you so much for the attetion and answer <3 That is very strange, because as long as @{Ataque} resolves to a number, it works. So either there's an issue in your template that you added it to, or there's an issue with your attribute. Without seeing either, I can't say where exactly the error is. Sorry, i was trying but  @{Ataque}  was with a max option, i tried now and works. But its the same problem of the other resolution, the 3d dice isnt working. is there a way to the 3d dice works?
Jarren said: timmaugh said: yes, since you can use scripts, you can do what you want. There's probably a way to do this with ScriptCards, and maybe Jarren can pipe in and offer a suggestion as to how. Just saw this haha - I’m not a Scriptcards user; I think you’re confusing me with Joshua N.  :) Michael B. said: timmaugh said: Thank you so much, it work but unfortunately the dice animation did not work, and i like to see this animation. I had a way to do this? Thank you for yout time <3 Unfortunately the dice animation only displays for native Roll20 rolls using the Quantum Roll generator.  The final dice expression that was made there doesn’t include a dice roll anymore because it was hidden within inline roll brackets. I’m not sure if it would be possible to hide the entire calculation and reuse the roll for display purposes to still show the 3D dice.  Oww, thats really sad :( but thanks for the answer anyway <3
For dice rolls to animate the rolls have to be in the most recent set of rolls for a shown message. So API solutions won't display rolls and Tuo's approach 'overrides' the last set of rolls sent to the roll server. With a different approach you can get the desired behaviour and dice animation using [[ floor({1,1,1,1,1,1,1,1,1,6 +4 +@{Ataque}}kl[[1d10]]/2) +4 +@{Ataque} ]] This rolls a standard d10 but then translates it into a d10 with the 10 replaced by the an amount that gives you the appropriate bonus. Since the outer roll doesn't have any random elements it doesn't prevent the nested roll from being animated.
1726525811
Andrew R.
Pro
Sheet Author
You can also use the  MetaScriptToolbox to do conditionals. I’ve used it to automate 13th Age attacks for my players. I’ve no idea what happens with 3D dice because I’ve never used them. 
1726581333
timmaugh
Pro
API Scripter
Jarren said: timmaugh said: yes, since you can use scripts, you can do what you want. There's probably a way to do this with ScriptCards, and maybe Jarren can pipe in and offer a suggestion as to how. Just saw this haha - I’m not a Scriptcards user; I think you’re confusing me with Joshua N.  :) Ach! You're probably right! I could have sworn you used ScriptCards, too! It probably owes to a quirk about the way I read... when I read, I often down see character names. My eye just attaches the mental image I have of the character to the general text pattern I'm seeing. Malchius? Got it... M-name is a spindly dude with wings. ...later we get a Melzichor? Ok. M...z name is a brooding fellow who can summon fire magic. Malchius is now a M...ch name attached to that spindly dude with wings. Thus endeth the path you never chose: a glimpse inside timmaugh's brain. Go, now, and be excellent to one another. =D
1726581646
timmaugh
Pro
API Scripter
Michael B. said: timmaugh said: !&{template:default} {{name=Investida Scorbunny}} {{Acerto = 100%}} {{Acerto Seguido= 100%}} {{Investida= {&r}(floor([[1d10]]/2) + 4 + @{Ataque}) {&if $[[0]] = 10}* 1.5{&end} {&/r} }} {{Tipo = Normal}} {{Descrição = Golpe Únicamente de Dano}} {&simple} Thank you so much, it work but unfortunately the dice animation did not work, and i like to see this animation. I had a way to do this? Thank you for yout time <3 Unfortunately, as RainbowEncoder said, once the scripts get involved, animated dice are lost. There is a trade-off for script functionality, but it's up to you what's more important.