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
This post has been closed. You can still view previous posts, but you can't post any new replies.

If / Then / else capability or at least score checking

1412821013
Falcon
Pro
Sheet Author
The ability to be able to use a script that would allow you to check whether someone gets hit. Instead of just # of successes it would give a TRUE or FALSE back as a attribute that you could then have other scripts follow. For example. If 18 hits an AC of 17 then apply damage to the character. This would be great for an entire host of other IF/THEN options.
Can't you already do this in an API script? or did you mean in a macro instead of in the API?
1412830240
Falcon
Pro
Sheet Author
Macro instead of an API because API are specific. I would like to do it for all APIs.
I would very much like a if / then / else makro, instead of and API so players could use it as well
+1. The issue with the API is that it's cool but unreliable. If you're playing a game and absolutely need the API for combat to to work, if it goes down or scripts crash it's catastrophic. Having simple if/then/else and SET statements core to Roll20 would be great.
I'd love this... Something like (pseudo code inc) var num roll = [[1d20]] var num result = [[roll + 7]] If (roll == 20) { var num dmg = [[(2d8 + 6) * 2]]} Else { var num dmg = [[2d8 + 6]]} Out: "/me attacks with my lightsaber! " + result Out: "/me deals " + dmg In general I just wish the macro options were more robust.
1454270184

Edited 1454272066
Henry W. said: I'd love this... Something like (pseudo code inc) var num roll = [[1d20]] var num result = [[roll + 7]] If (roll == 20) { var num dmg = [[(2d8 + 6) * 2]]} Else { var num dmg = [[2d8 + 6]]} Out: "/me attacks with my lightsaber! " + result Out: "/me deals " + dmg In general I just wish the macro options were more robust. Doesn't even need to be that complicated, it could work like a roll query. Have your standard bonus attribute set to 7 and: /me attacks with my lightsaber ?{if|[[1d20cs>20+@{bonus}]] >= @{target|target|AC},and hit for [[2d8+6]] damage|else, but misses!|critical, ?{if|[[1d20+@{bonus}]] >= @{target|target|AC}, +[[2d8+6]] critical damage}}! Mouse-over would have to show the conditional statement though so the GM can check for cheating. Btw, you should probably look at the dice reference on the wiki. It already has  built-in critical thresholds ; the Pathfinder character sheet automatically handles rolling critical confirms and critical damage in its default macros, so maybe look into character sheets and see if there's one that'll work for your system. And @{target|target|AC} is  already a thing .
1454279428
Falcon
Pro
Sheet Author
Rory C. said: Henry W. said: I'd love this... Something like (pseudo code inc) var num roll = [[1d20]] var num result = [[roll + 7]] If (roll == 20) { var num dmg = [[(2d8 + 6) * 2]]} Else { var num dmg = [[2d8 + 6]]} Out: "/me attacks with my lightsaber! " + result Out: "/me deals " + dmg In general I just wish the macro options were more robust. Doesn't even need to be that complicated, it could work like a roll query. Have your standard bonus attribute set to 7 and: /me attacks with my lightsaber ?{if|[[1d20cs>20+@{bonus}]] >= @{target|target|AC},and hit for [[2d8+6]] damage|else, but misses!|critical, ?{if|[[1d20+@{bonus}]] >= @{target|target|AC}, +[[2d8+6]] critical damage}}! Mouse-over would have to show the conditional statement though so the GM can check for cheating. Btw, you should probably look at the dice reference on the wiki. It already has  built-in critical thresholds ; the Pathfinder character sheet automatically handles rolling critical confirms and critical damage in its default macros, so maybe look into character sheets and see if there's one that'll work for your system. And @{target|target|AC} is  already a thing . I have already worked through all the built-in critical thresholds and such.  The issue is if you want to evaluate a previous roll.  You can't do that now.  If you roll to hit and then have another macro that determines damage based on what you rolled, for example.  It would be better to simply have a if/then/else capability built into the macro system.  They did it for the roll templates but not for macros.
Black Falcon said: Rory C. said: Henry W. said: I'd love this... Something like (pseudo code inc) var num roll = [[1d20]] var num result = [[roll + 7]] If (roll == 20) { var num dmg = [[(2d8 + 6) * 2]]} Else { var num dmg = [[2d8 + 6]]} Out: "/me attacks with my lightsaber! " + result Out: "/me deals " + dmg In general I just wish the macro options were more robust. Doesn't even need to be that complicated, it could work like a roll query. Have your standard bonus attribute set to 7 and: /me attacks with my lightsaber ?{if|[[1d20cs>20+@{bonus}]] >= @{target|target|AC},and hit for [[2d8+6]] damage|else, but misses!|critical, ?{if|[[1d20+@{bonus}]] >= @{target|target|AC}, +[[2d8+6]] critical damage}}! Mouse-over would have to show the conditional statement though so the GM can check for cheating. Btw, you should probably look at the dice reference on the wiki. It already has  built-in critical thresholds ; the Pathfinder character sheet automatically handles rolling critical confirms and critical damage in its default macros, so maybe look into character sheets and see if there's one that'll work for your system. And @{target|target|AC} is  already a thing . I have already worked through all the built-in critical thresholds and such.  The issue is if you want to evaluate a previous roll.  You can't do that now.  If you roll to hit and then have another macro that determines damage based on what you rolled, for example.  It would be better to simply have a if/then/else capability built into the macro system.  They did it for the roll templates but not for macros. I should probably mention that I'm 100% a +1 for conditional macros, btw. There's no reason this shouldn't be an option. I've been considering writing an API script to allow players to get access to conditional statements, but it gets tricky when you start having it automatically apply damage like one of your suggestions. A player could write a macro using the script with a +9999 to attack and a +9999 to damage, and have it apply to a character. Basically I'd have to push a confirmation to the GM via GM Whisper that includes all the listed attributes and the GM would have to click an 'Ok' box confirming the roll before it would apply to the target. On top of all that, I'd have to write a function that would parse the provided macro and basically bypass the built-in macro system, but still follow all the rules of the system to-the-letter. Add into the fact that there may be conditional modifiers, such as if (target|type|sub-type == 'goblin'){damage = damage+2}; that would have to be accounted for by the end-user, and to my knowledge the pathfinder sheet doesn't have a sub-type field. Anyway, it's doable but it would be a pretty big undertaking and only be available to Pro GM's. Having built-in conditional queries following something like ?{if| bool, result|else, result2|optional-condition, result 3...} just plain built into the system would be so much easier. Plus roll queries' order of operations is a PITA, and makes the query bug out half the time.
1454310953
Falcon
Pro
Sheet Author
I think someone has already created something like that.  I would check with The Aaron as he knows all macros. Completely agree with your assessment of what is needed.
I wonder if advanced macro capabilities could be added as a Pro feature? I'm a Pro subscriber, and while I use some API scripts that others in the community have provided (Thanks to all of you coders out there!), I will probably never write my own API script. However, I can do basic conditional logic, and would love to have a way to do this in macros. I don't know if the macro feature set can be divided by subscriber level, but something in between the current macro language and the API would be nice IMO.
Amen to this
+1
+1
1466872071

Edited 1466872499
Rory C. said: Henry W. said: I'd love this... Something like (pseudo code inc) var num roll = [[1d20]] var num result = [[roll + 7]] If (roll == 20) { var num dmg = [[(2d8 + 6) * 2]]} Else { var num dmg = [[2d8 + 6]]} Out: "/me attacks with my lightsaber! " + result Out: "/me deals " + dmg In general I just wish the macro options were more robust. Doesn't even need to be that complicated, it could work like a roll query. Have your standard bonus attribute set to 7 and: /me attacks with my lightsaber ?{if|[[1d20cs>20+@{bonus}]] >= @{target|target|AC},and hit for [[2d8+6]] damage|else, but misses!|critical, ?{if|[[1d20+@{bonus}]] >= @{target|target|AC}, +[[2d8+6]] critical damage}}! Mouse-over would have to show the conditional statement though so the GM can check for cheating. Btw, you should probably look at the dice reference on the wiki. It already has  built-in critical thresholds ; the Pathfinder character sheet automatically handles rolling critical confirms and critical damage in its default macros, so maybe look into character sheets and see if there's one that'll work for your system. And @{target|target|AC} is  already a thing . Things like "/me attacks with my lightsaber ?{if|[[1d20cs>20+@{bonus}]] >= @{target|target|AC},and hit for [[2d8+6]] damage|else, but misses!|critical, ?{if|[[1d20+@{bonus}]] >= @{target|target|AC}, +[[2d8+6]] critical damage}}!" give me, and especially my players, a complete headache. I never figured out why Roll20 uses some unique set up for macros instead of just using API for everything. var num roll = [[1d20]] var num result = [[roll + 7]] If (roll == 20) { var num dmg = [[(2d8 + 6) * 2]]} Else { var num dmg = [[2d8 + 6]]} Out: "/me attacks with my lightsaber! " + result Out: "/me deals " + dmg ^^ This was instantly understandable to me and clear as day as to what is going on. On most macros, however, I have to sit for a while and try to decipher hieroglyphics.
1479251498
Mike W.
Pro
Sheet Author
+1
This is remaining API only for the foreseeable future.