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

If logic

Hello, Can someone confirm whether or not I can use conditional logic? From what I've seen even the API is somewhat limited in it's capabilities. I currently have a free subscription and before I upgrade I want to know what I can actually do. In either free or paid can I have an if(selected token roll >= target token ac,roll damage,"Miss") I would also like to have the damage automatically deduct from the target token's HP but I'm sure that's a bit of a stretch. So far for the free subscription the best option I've seen is to have a macro just roll both hit and damage and while playing we would have to make the decision of whether or not to use the resulting damage. Thanks in advance for any help.
Just recently, roll templates have done some pseudo if/then logic, but from my understanding it is mostly cosmetic (it hides or reveals rolls). The API can do the automatic deduction, but I am not sure exactly how to do it. If you want a really quick output of damage you can do something along the lines of: /me swings his sword doing [[ [[d20>@{target|AC}]] * @{selected|weapon_damage} ]] damage. Though there is probably a better way, and I think that would hide critical hits.
1432149126
The Aaron
Roll20 Production Team
API Scripter
Macros cannot provide any sort of automation. They are effectively a formula where you supply the values and get back an answer. They cannot be used to change anything (with the exception that you can use a macro to set the Turn Order entry for a token). (see: <a href="https://wiki.roll20.net/Macros" rel="nofollow">https://wiki.roll20.net/Macros</a>) Roll Templates can selectively display information. For example, they could be used to show the critical hit damage in the event that a roll was a critical hit. Roll Templates are a part of the Character Sheet system, and so creating and using custom ones is a Mentor Level Perk . (see: <a href="https://wiki.roll20.net/Roll_Templates" rel="nofollow">https://wiki.roll20.net/Roll_Templates</a> The API is a full Javascript Sandbox. It can do extremely complicated logic, involving automation and content creation on many levels. It has some limitations, but it's getting better all the time. What you described is extremely doable in the API, which is also a Mentor Level Perk . (see: <a href="https://wiki.roll20.net/API:Introduction" rel="nofollow">https://wiki.roll20.net/API:Introduction</a>)
great thanks.
1432199952
Sam
Pro
Sheet Author
As far as hiding critical hits. Feel free to look at / use how the Pathfinder character sheet is doing it. Tristan if you are only needing some if logic for calculations and you can use the logical equivalents of 1 and 0. After all, anything multiplied by 1 is itself and anything multiplied by 0 is zero. So therefore it follows that if you want to conditionally allow a modifier in your roll you can do something like 1d20 - ?{Power Attack|0} * (@{level}) 1d8 + ?{Power Attack|0} * (@{level} * 2) If you want to invert the logical statement you can say (1 - ?{Your Query|0}) . This works because 1 - 0 = 1 and 1 - 1 = 0 . Yes, these are still pretty simple examples but using a combination you can do some pretty cool things. Also queries with the same name (everything before the optional vertical pipe) will only prompt the user once because queries with the same name share the input value. The format for a query is ?{ Query Name [ | Optional Value] }. The optional value is what will show up by default in the query box when it pops up. In cases of a numeric I default to whatever makes sense for my roll. Hope that helps. If you have any other questions, feel free to shoot me a line.
The next version of the powercards api script will soon have the capability to do basic if statements. It's still being worked on though. Trying to quash some bugs.