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

Need Macro Help

1456615305
PhailedGamer
Pro
Sheet Author
I'm no expert with these macros so I thought I'd see if anyone would know something I've missed in my research. I'm using this as the basic template for the rolls in Qin: The Warring States. &{template:default} {{name=Yin/Yang Roll}} {{Yin Roll=[[1d10]]}} {{Yang Roll=[[1d10]]}} What I'm hoping to figure out a way to do, however, is to subtract the smaller of the two rolls from the larger. It's an interesting game mechanic that I can't seem to figure out how to emulate in Roll20. I had considered just subtracting the second from the first and treating any negative result as their positive equivalent but if there's a way to simulate the mechanic I need, I'd prefer that.
1456616990
Diana P
Pro
Sheet Author
[[abs(1d10 - 1d10)]] would give you the absolute value of subtracting the 2nd from the first so it would always look positive.  If you don't like the colored borders, you could use [[abs(1d10cf<0cs>11 - 1d10cf<0cs>11)]] to move the critical fail and critical success points outside of the values that you can roll. Hope that helps.
1456617140

Edited 1456617214
Silvyre
Forum Champion
Here's the documentation for the abs() function.
1456617756

Edited 1456626181
This is actually something PowerCards could help you with, using Roll ID's. !power {{ --name|Yin/Yang --Yin:|[! [^Yin] !] --Yang:| [! [^Yang] !] --Result:|[[ [NH] abs([$Yin] 1d10 - [$Yang] 1d10)]] --?? $Yin = $Yang ?? Balance:|Your yin and yang are in balance! }}
1456618368

Edited 1456618485
PhailedGamer
Pro
Sheet Author
Forgot about the abs() function. Then I guess the only thing that I'm hung up on is a way to distinguish between which roll specifically is the Yin Roll and which is the Yang Roll. Is there a way maybe to take the roll results used within the template and apply them elsewhere within the template? As an example (and I know this is incorrect but you'll get the idea): &{template:default} {{name=Yin/Yang Roll}} {{Yin Roll=[[1d10]]}} {{Yang Roll=[[1d10]]}} {{Result=abs(@{Yin Roll}-@{Yang Roll})}} The idea being that I can still see the result of the individual rolls and which die (Yin/Yang) they apply to as well as getting the end result. The abs() function already solved an issue I had with automating initiative rolls and adding them to the tracker so thank you very much for that. Attack and Defense rolls, however, need to know which die is dominant for applicable bonuses. Edit: Looks like PowerCards would do it. Thank you very much. Can I plug that into a sheet roll for the custom sheets I'm using? (I have no experience with the API).
Outside of using an API script, no... there's no way to use roll results elsewhere in the template.
1456618662

Edited 1456618753
First, you need to install the powercards script on your campaign page under Settings: <a href="https://app.roll20.net/forum/permalink/2165711/" rel="nofollow">https://app.roll20.net/forum/permalink/2165711/</a> Then&nbsp;you can plug in what I wrote above anywhere you use a macro. If it's in a character sheet roll button, you'd get rid of the curly braces and put it all on one line like this: !power --name|Yin/Yang --Yin:|[! [^Yin] !] --Yang:| [! [^Yang] !] --Result:|[[ [NH] abs([$Yin] 1d10 - [$Yang] 1d10)]]
1456619179
PhailedGamer
Pro
Sheet Author
Thank you very much for the assistance. Looks like I'll have to get familiar with API as well now. As a side note, I am continually amazed at the helpfulness of the Roll20 community and am very happy with my decision to subscribe.
You may have to escape some characters when using a powercard macro in a character sheet. I've never actually done that. Trial and error I suppose. :D
1456623205
PhailedGamer
Pro
Sheet Author
Everything worked perfectly and even figured out enough to make a couple changes in order to use them in the sheet macros. One more thing I was trying to do was to compare the final result to 0 and then trigger a statement. I tried adding some lines after the Result: that looked like variations of this: -- ?? $Result == 0 ?? Balance:|Your Yin and Yang are in balance! and -- ?? $Yin - $Yang == 0 ?? Balance:|Your Yin and Yang are in balance! as well as --?? [$Yin] - [$Yang] == 0 ?? etc etc
Use this instead: --?? $Yin == $Yang ?? Balance:|Your yin and yang are in balance!
1456624465
PhailedGamer
Pro
Sheet Author
Awesome. Thank you.
1456625227
PhailedGamer
Pro
Sheet Author
Ok, I tried using that command line. Unfortunately, no matter the result of the two dice though, it triggers balance. Also tried replacing $Yin and $Yang with: [$Yin] and [$Yang] ^Yin and ^Yang [^Yin] and [^Yang]
That's because I am a dumbass... you only need one equal sign. Not two. --?? $Yin = $Yang ?? Balance:|Your yin and yang are in balance!
1456626105
PhailedGamer
Pro
Sheet Author
Same result unfortunately.
Working on this. Trying to see why it isn't doing what it should be doing.
Ok, figured it out... it is supposed to be == and not = and you need to be comparing .base on each one. Confusing and annoying, but it's because they're in the same roll.&nbsp; -- ?? $Yin.base == $$Yang.base ?? Balance:|Your yin and yang are in balance!
1456627104
PhailedGamer
Pro
Sheet Author
Perfect! Thank you.
1456647827
PhailedGamer
Pro
Sheet Author
So, ran into a new snag. I was setting up the initiative macro and that's where it hit. When rolling the two dice, I need to be able to call up the results of one of them later to add to another formula. Can't seem to figure out how to work that without getting an error or crashing the API. This is what I'm currently using for initiative (token action): !power {{ --name|@{selected|token_name}'s Initiative Roll --tokenid|@{selected|token_id} --Water Score:|@{selected|Water} --Yin:|[! [^Yin] !] --Yang:| [! [^Yang] !] --Initiative:|[[ [NH] @{selected|Water} + abs([$Yin] {1d10-1} - [$Yang] {1d10-1}) [trkr] ]] -- ?? $Yin.base == $Yang.base ?? Balance:|Your Yin and Yang are in balance! Add one of your dice to the result. }} This is what I would like to achieve (or something cleaner): !power {{ --name|@{selected|token_name}'s Initiative Roll --tokenid|@{selected|token_id} --Water Score:|@{selected|Water} --Yin:|[[ [$Yin] {1d10-1} ]] --Yang:|[[ [$Yang] {1d10-1} ]] -- ?? $Yin == $Yang ?? Balance:|Your yin and yang are in balance! -- ?? $Yin == $Yang ?? Balanced:| [[ [NH] @{selected|Water} + [$Yin] [trkr] ]] &nbsp; /*This [$Yin] using the result of the original roll */ -- ?? $Yin &lt;&gt; &Yang ?? Initiative:| [[ [NH] @{selected|Water} + abs([$Yin] - [$Yang]) [trkr] ]] &nbsp; /* These should also use the original roll */ }} The bolded areas are where I run into problems. As long as I don't try and call up the original roll, it's okay with whatever formula I choose to put in there. I've been looking through the forums trying to find another example where someone's called up a previously roll in a new formula so I could try to figure what I was doing wrong but haven't had much luck so far.
1456648265

Edited 1456648484
Silvyre
Forum Champion
In general, you'll need to combine [NH] and [trkr] into [NH|trkr] I also see &Yang instead of $Yang However, that's a bit inconsequential, as PowerCards is not yet capable of doing math with Roll IDs.
You can't use them that way. It's something I want to try and add someday, but it's very tricky.
1456649157
PhailedGamer
Pro
Sheet Author
Silvyre said: In general, you'll need to combine [NH] and [trkr] into [NH|trkr] I also see &Yang instead of $Yang However, that's a bit inconsequential, as PowerCards is not yet capable of doing math with Roll IDs. &Yang was a typo while I was plugging the information into the post. HoneyBadger said: You can't use them that way. It's something I want to try and add someday, but it's very tricky. Ahh, fair enough. I'll just handle that manually then unless I can figure out some other workaround. Thanks again.
1456687334

Edited 1456687836
Garrett, another way you could do this that is simple, but a lot of work up front, just make a 100 entry Rollable Table named something like YIN/YANG, with each entry weighed at 1. &nbsp;Set up each table entry like Yin 10 - Yang 10 =0, Yin 10 -Yang 9 =YIN 1, Yin 10 -YANG 8 =YIN 2, etc etc. &nbsp;Do that for 10 through 1, (or 0 through 9 if you are reading that way). &nbsp;100 entries. &nbsp;It is a lot of work, but basically you are building your own yin/yang dice in the form of a rollable table, & you can always use the transmorgrifier tool to move it to your other games. &nbsp; VERY IMPORTANT! &nbsp;If you do this, don't start your table entries with numbers -push the numbers behind other characters, like letters. &nbsp;Thus, instead of saying "10 YIN - 9 YANG" title the entry as YIN 1 - YANG 9 = YANG 8" etc etc. Then To set it up in your toolbar just use a simple macro not too much unlike what you were doing &{template:default} {{name=YIN & YANG ROLL}} {{[[1t[YIN/YANG]]]}} The [[x]] are where you have problems if you start your table entries with numbers. &nbsp;If you are just using 1t[YIN&YANG], starting with numbers doesn't matter, but the over-all presentation will look cluttered like when you use the /roll command in chat. &nbsp;If your tidying it up with [[x]] brackets "[[1t[YIN&YANG]]]' for the yellowed field, then that is when it becomes important to not begin your entries with numbers like i explained earlier. &nbsp;I don't know why it works like that it just does &nbsp;;) In fact i might build one of these just for giggles since i am actually OCD enough to do it! &nbsp;:) You could accomplish the same with a 100 card deck, & make it a decorative labor of love, depending on how much artwork you wanted to devote to the cards. &nbsp;You could have a spectacular looking deck though if you wanted to do it! Hope that contains something useful. &nbsp;Admittedly, my suggestion is quite a bit of work, but it it will produce what you are looking for if i understand you correctly.
1456688533
PhailedGamer
Pro
Sheet Author
I actually hadn't thought of using a rollable table. This would allow me to get the same results without using an API. Unfortunately, the final hurdle I encounter still remains. I can't use the result in other computations (as far as I know). That's kind of the sticky bit for the mechanic. Your idea, however, may work for a different game I have that accesses a table for roll results. I'm currently just referencing the table while playing but your way would actually allow me to just put the table into game and let the players roll and get their results in game.
Garret, i am not familiar with the system of Qin, or how the mechanics work, but the impression i get from the examples your citing is that you could achieve your second goal by adding a general query to your macros so that you can fill in the number value to the yin or yang. &nbsp;Sure you would have to punch the value in manually each time you used the macro so it may not be quite as automated as you hoped, but it would still read out the results in chat & associate them with yin or yang as designated. &nbsp;Basically like query rolls for saving throws, ability checks, attacks etc that always ask you for a generalized "other modifiers" that are defaulted at zero but you can fill in with a different number value if there is one. &nbsp;I can't post an example tonight, it is just too late & i need to sleep &nbsp;:) For my AD&D games, all my macros as matter of policy include a general query in them so the roll can accommodate those variable, situational modifiers that come up in the course of play.&nbsp;