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.

[Script] PowerCards 3 (Thread 4)

Silvyre said: Post the full macro. Here it is: !power {{ --tokenid|@{selected|token_id} --emote|**@{selected|token_name}** attempts to disarm **@{target|1st|token_name}**! --name|Disarm --Attack:|~R[[ [NH] {(@{selected|Dexterity} + @{selected|Melee} + ?{Pool Mod|0} +1)d10s}>?{Difficulty?|6}f1 ]] **Successes**~R --If Hit:|If **@{character_name}’s** [[ [nh] {(@{selected|Strength}+1)d10s>6f1} ]] successes are greater than **@{target|1st|token_name}‘s** Strength [[ [nh] {(@{target|1st|Strength})d10s>6f1} ]], **@{target|1st|token_name}** is disarmed! }} Trying to figure out a way to automatically add 1 to the "Difficulty" section. Not a big deal if we can't, would just be nice.
Just to make sure, when you're testing this macro, you're first saving it as an Ability, right?
1483077915

Edited 1483078305
[[{3d10s}>[[?{Difficulty|4}+1]]f1]] Tested this in Roll20 chat without going through the api and it is resolving correctly to difficulty 5 if I just hit enter. edit - This works through powercards v3.2.22. Also tested with both xpnd and rpnd, with and without nh and nh by itself. All are working as intended. !power --name|Test --Result:|[[{3d10s}>[[?{Difficulty|4}+1]]f1]]
Silvyre said: Just to make sure, when you're testing this macro, you're first saving it as an Ability, right? Correct
SkyCaptainXIII said: [[{3d10s}>[[?{Difficulty|4}+1]]f1]] Tested this in Roll20 chat without going through the api and it is resolving correctly to difficulty 5 if I just hit enter. edit - This works through powercards v3.2.22. Also tested with both xpnd and rpnd, with and without nh and nh by itself. All are working as intended. !power --name|Test --Result:|[[{3d10s}>[[?{Difficulty|4}+1]]f1]] This worked beautifully. Didn't have the double brackets before and after the Difficulty section. Thanks SkyCaptian!
1483299358

Edited 1483299499
Dad
Pro
Hello, So, I'm trying to create an attack damage macro for my player's character sheets, with the macro going to one of two different damage roll formulas based off a weapon's special effect. The macro so far is as follows !power {{ --name|Damage! -- !tearing? | [[ [$Tear](1d1+@{rangedweapontearing})]] -- ?? $Tear.total = 2 ?? tearing: | Tearing! -- ?? $Tear.total = 1 ?? not_tearing | Not Tearing! }} The attribute @{rangedweapontearing} is a binary variable controlled by a checkbox on the character sheet, and the macro will return a value of 1 or 2. But, as it is though, the macro won't spit out either of the responses "Tearing!" or "Not Tearing!" and I have no idea why.
GM-kun said: ?? $Tear.total = 2 ?? ?? $Tear.total = 1 ?? Your comparison operators are missing an equals sign each. ==
Oh! Fantastic, thank you. Figures it'd be something that simple.
1483570704
Garrett K.
Marketplace Creator
Seems to be some sort of bug involving placing multiple command buttons under a given tag. Two seems alright, however at three, it starts displaying them as links. I've actually had trouble after that, getting previously working configurations to function again.. Everything seems to function normally so long as each command button is given its own tag however. Anyone run in to something like this before?
I'd post the macro that you're having issues with.
1483727643
Garrett K.
Marketplace Creator
Silvyre said: I'd post the macro that you're having issues with. Always have issues with putting text into these boxes properly, so I included a screenshot of the macro, and the result. I have highlighted what I'm trying to get to work.. That's what's popping up in the bottom right as 0 / 1 / [ 2 ] All three of those should be buttons, and this problem seems to happen to me often. Whenever I try to put more than one button on a line, it gets weird. Most of the time I can do 2 buttons, as you can see with Arcane / Divine, however even two buttons wouldn't work when labeled as numbers? I'm so confused :(
1483727827
Garrett K.
Marketplace Creator
Here's the same concept, cleaned up a bit, and with neither command box working... where just above them I have 5 working in a row with a nearly identical layout
1483733634

Edited 1483737270
PowerCards is parsing the ~L within two of your Command Buttons as its left-align syntax (see OP for documentation). !power {{ --name|Minimal Test Case --whisper|all --!|[B](~L|1) [B](~L|1) [B](~L|1) }} This unfortunately means that some Ability Command Buttons which use a Character's name (starting with L, C, R or J ) as a keyword won't work within PowerCards. You can work around this issue in several ways: Escape the ~ using its HTML entity. e.g. Replace [Arcane](~L0Arcane|List) with [Arcane](~L0Arcane|List) Use a Character's ID as a keyword (instead of its name). e.g. You can find the character_id of L0Arcane using @{L0Arcane|character_id} Use API Command Buttons instead. e.g. Replace [Arcane](~L0Arcane|List) with [Arcane](!
 %{L0Arcane|List}) Rename each Character (such that their names do not begin with L, C, R or J) e.g. Rename the L0Arcane Character to ArcaneL0
1483745140
Garrett K.
Marketplace Creator
Silvyre said: PowerCards is parsing the ~L within two of your Command Buttons as its left-align syntax (see OP for documentation). !power {{ --name|Minimal Test Case --whisper|all --!|[B](~L|1) [B](~L|1) [B](~L|1) }} This unfortunately means that some Ability Command Buttons which use a Character's name (starting with L, C, R or J ) as a keyword won't work within PowerCards. You can work around this issue in several ways: Escape the ~ using its HTML entity. e.g. Replace [Arcane](~L0Arcane|List) with [Arcane](~L0Arcane|List) Use a Character's ID as a keyword (instead of its name). e.g. You can find the character_id of L0Arcane using @{L0Arcane|character_id} Use API Command Buttons instead. e.g. Replace [Arcane](~L0Arcane|List) with [Arcane](!
 %{L0Arcane|List}) Rename each Character (such that their names do not begin with L, C, R or J) e.g. Rename the L0Arcane Character to ArcaneL0 Method #1 caused 100+ iterations of the button to appear Method #2: Button appears correctly, however clicking causes following error: TypeError: l is undefined Method #3: Not sure I understand this one as being different from method 1? I thought all of these methods were an attempt to create API command buttons? In which case isn't this a reformatting of method #1? Method #4: I am avoiding this one as it would require altering many existing macros which are dependent on the LXArcane naming structure, though it seems like this might be the most straightforward solution.
1483749125

Edited 1483749144
Garrett K. said: Method #2: Button appears correctly, however clicking causes following error: TypeError: l is undefined An Ability Command Buttons that uses a Character's ID as its keyword looks like this: [Label](~ -K_-px2ekOzVBEUPDM5p |Ability) Does that looks like what you had set up? Garrett K. said: Method #3: Not sure I understand this one as being different from method 1? This uses API Command Buttons instead of Ability Command Buttons . In both cases, HTML entities are involved. Some users are more familiar with the older API CBs than they are with the newer Ability CBs. Garrett K. said: Method #1 caused 100+ iterations of the button to appear Was not my experience. If you're interested in troubleshooting this, I'll need you to post the full macro in question, as text, with HTML entities intact .
I'll look into the alignment options and see about ignoring those. Not sure when I'll get a chance to do that though. It's my long weekend to work.
1484565299
Ziechael
Forum Champion
Sheet Author
API Scripter
Is there a way to use hidden URL's where the URL in question has double -'s in it. Using html replacements results in the url+the label displaying as a link whereas using the URL as is obviously reads the -- as the start of a new tag :/
I don't know that it would be possible. That's one of the very first things the script does. Had that problem with character and token id's that ended up with a double dash in it as well and was unable to fix it.
1484573109
Ziechael
Forum Champion
Sheet Author
API Scripter
I kinda figured as much stupid web designers and their stupid url naming conventions ;) No worries though, thanks for confirming... any way to open a handout from a powercard (fairly certain I recall the answer being no bar a 'button' being used to do it?)
I can't remember if the API has access to opening handouts or not.
1484574060
The Aaron
Pro
API Scripter
SkyCaptainXIII said: I can't remember if the API has access to opening handouts or not. Does not, but can provide a link to it.
1484574387
The Aaron
Pro
API Scripter
SkyCaptainXIII said: I don't know that it would be possible. That's one of the very first things the script does. Had that problem with character and token id's that ended up with a double dash in it as well and was unable to fix it. Change line 78 to this:     var n = (player_obj) ? msg.content.replace("%%who%%", player_obj.get("displayname")).split(/\s+--/) : msg.content.split(/\s+--/); That will fix the embedded -- issue by splitting arguments on (1+ spaces followed by --).
Oh nice. Will get to that here in a bit. Thanks!
1484577148
The Aaron
Pro
API Scripter
No worries, just trying to get back in the swing of being an ever present benevolent scriptomancer. =D
January 16th, 2017 ~ 9:50 am eastern Version: 3.2.23 Link: gist.github.com/Sky-Captain-13/452330a3d926b32da49c Minor Update: Added double dash fix from TheAaron for urls. Should solve the old issue with double dashes in token and character id's too.
1484578499
The Aaron
Pro
API Scripter
BTW, I think they've gotten rid of the auto expansion of gist urls, so you can use: <a href="http://gist.github.com/Sky-Captain-13/452330a3d926" rel="nofollow">http://gist.github.com/Sky-Captain-13/452330a3d926</a>...
Oh cool.
1485835975

Edited 1485836003
I came across an issue where attributes that were expanded via target charms were just replaced with the text for the attribute formula and not the final value of the attribute. For example, using %%ref%% as a target charm (with the D&D 4E character sheet) results in "10 + floor((18-10)/2) + 2 + 0 + 0 + 0 + 0)" instead of the desired "16". Using [[ ]] around the target charm obviously doesn't work since the Roll20 parser tries to evaluate the inline roll expression before PowerCards runs. I changed the default case of the getTargetInfo() method of your script to allow for optional inline bracketing after the attribute has been expanded, by adding an extra % on the first part of the charm, like %%%ref%%. I made it optional because if you use an attribute like token_name in the charm the inline roll will cause an error because it's not a number. default: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var addBraces = false; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (charm.indexOf("%") === 0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; charm = charm.replace("%", ""); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addBraces = true; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; attr = getAttrByName(Character.id, charm); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; attr = getAttrRefValues(Character.id, attr); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (addBraces) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; attr = "[[" + attr + "]]"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (Character && attr) || 'ERROR';
Is there any way to have it so my players can't see the dice roll, just the total amount, but still have the functionality of $Atk variable? Currently I can only find a really roundabout way of doing it, which looks hideous and isn't ideal. This is my workaround so far: --Attack|[[ [$Atk] 1d0+[[ 1d20 + 4]] ]] vs AC --?? $Atk.total == 5 ?? Miss|Your attack missed --?? $Atk.total &lt;&gt; 5 AND $Atk.total &lt;&gt; 24 ?? Hit|[[1d4+2]] damage --?? $Atk.total == 24 ?? Critical|[[2d4+2]] damage This is fine if I don't want to use variables in the rolls, but I would like to be able to have a single macro that I can use with it calling for my input on the attack values and damage values etc.&nbsp; The problem I have is I can't seem to figure a way where I can add that variable to the last set of functions. eg: --Attack|[[ [$Atk] 1d0+[[1d20 + ?{Attack bonus}]] ]] vs AC --?? $Atk.total == 1+?{Attack bonus} ?? Miss|Your attack missed etc Is there a way to make the script realise the variable (Attack bonus) needs to be added to the 1, or 20, or the other option, before it resolves whether it is true or false? Bonus question, is there going to be an option in the future for a simple !hideroll function like that of the default script?
Tao said: Bonus question, is there going to be an option in the future for a simple !hideroll function like that of the default script? There's --hroll for this purpose (although I see it's not currently documented in this thread): !power {{ --hroll|[[ [$Atk] 1d20 + 10 ]] --Attack|[^Atk.total] or [! [^Atk.total] !] vs AC }}
Awesome, I should be able to mash together a script for what I want now. Thanks!
Silvyre said: Tao said: Bonus question, is there going to be an option in the future for a simple !hideroll function like that of the default script? There's --hroll for this purpose (although I see it's not currently documented in this thread): !power {{ --hroll|[[ [$Atk] 1d20 + 10 ]] --Attack|[^Atk.total] or [! [^Atk.total] !] vs AC }} Ran this and apparently there's a bug. [! [^Atk.total] !] is not showing the full total, just the base roll for some reason. Fun.... _&lt;
SkyCaptainXIII said: Silvyre said: Tao said: Bonus question, is there going to be an option in the future for a simple !hideroll function like that of the default script? There's --hroll for this purpose (although I see it's not currently documented in this thread): !power {{ --hroll|[[ [$Atk] 1d20 + 10 ]] --Attack|[^Atk.total] or [! [^Atk.total] !] vs AC }} Ran this and apparently there's a bug. [! [^Atk.total] !] is not showing the full total, just the base roll for some reason. Fun.... _&lt; You have to use either [^Atk.total] OR [! [^Atk.total] !] Using them both in the same line returns incorrect values. The first one is used if you dont want the roll to look like a normal [[]] roll. The second one looks exactly like if you used a normal [[]] roll.
It shouldn't matter if they're both used. A curious bug indeed.
Silvyre said: There's --hroll for this purpose (although I see it's not currently documented in this thread): Fixed.
Tao said: Using them both in the same line returns incorrect values. The first one is used if you dont want the roll to look like a normal [[]] roll. The second one looks exactly like if you used a normal [[]] roll. Yeah.... &nbsp;I know. I wrote the script. :D
Question for everyone... looking into some oddities concerning keep/drop high/low rolls and how they interact with conditionals and when using the roll id without dot options ($R vs $R.base or $R.total)... What is your expectation when you use $R without any options? Are you expecting the full modified roll (.total) or just the roll without modifiers (.base)? I'm pretty sure they're not consistent at the moment and am looking at making them work the same regardless of where used.
1486759417
Ziechael
Forum Champion
Sheet Author
API Scripter
Personally I would expect a bare roll id to default to the total of the roll in question (and have probably used it as such many times). I tend to use .base and .total on my modern cards to ensure that they are using what I want but can't recall ever getting undesirable behaviour when using just the bare id and hoping for the total... The main reason I'd expect the bare id to default to total is that it is the id for the whole roll and therefore should only need telling to do something different when you want something different such as .base? :)
That's pretty much my thought. Just want to make sure that's what others feel as well.
Turns out the only inconsistency was with displaying a roll id using [^Roll]. It defaulted to base instead of total. I changed one word on one line and fixed the inconsistency I had noticed. Will look at doing some more work this weekend before putting out an update.
I modified your script to prevent incorrect power card roll expression syntax from throwing an error and killing the API sandbox. The issue was my players were experimenting with power cards during off-hours and I was having to log in and reset the sandbox any time they made a syntax mistake. All I did was replace all instance of sendChat in the script to call safeSendChat, which is this function I added: function safeSendChat(speakingAs, message, callback) { &nbsp; &nbsp; try { &nbsp; &nbsp; &nbsp; &nbsp; sendChat(speakingAs, message, callback); &nbsp; &nbsp; } &nbsp; &nbsp; catch (e) { &nbsp; &nbsp; &nbsp; &nbsp; sendChat("PowerCards", JSON.stringify(e)); &nbsp; &nbsp; } } This also sends the error message back out to the chat log so they can hopefully discern the cause of the error.
Shaangor said: I modified your script to prevent incorrect power card roll expression syntax from throwing an error and killing the API sandbox. The issue was my players were experimenting with power cards during off-hours and I was having to log in and reset the sandbox any time they made a syntax mistake. All I did was replace all instance of sendChat in the script to call safeSendChat, which is this function I added: function safeSendChat(speakingAs, message, callback) { &nbsp; &nbsp; try { &nbsp; &nbsp; &nbsp; &nbsp; sendChat(speakingAs, message, callback); &nbsp; &nbsp; } &nbsp; &nbsp; catch (e) { &nbsp; &nbsp; &nbsp; &nbsp; sendChat("PowerCards", JSON.stringify(e)); &nbsp; &nbsp; } } This also sends the error message back out to the chat log so they can hopefully discern the cause of the error. Added this. Probably should have done something like this a long time ago, but I generally just figure out what I want to do and then start googling/stackexchanging until I find something that does something close and work with that. :D
Nice!
February 11th, 2017 ~ 10:00 am eastern Version: 3.3.0 Link: <a href="https://gist.github.com/Sky-Captain-13/452330a3d9" rel="nofollow">https://gist.github.com/Sky-Captain-13/452330a3d9</a>... Major Update: Added the --soundfx tag which integrates with the Roll20 Audio Master Scott C. script available as a one-click install script. To use this tag, you need to use the R20AM commands, but replace the -- of their tags with an underscore. To use multiple soundfx tags, just append a number to the end. --soundfx|_play|Bite --?? $Atk &gt;= @{target|AC} ?? soundfx1|_play|Shortbow Minor Update: Included error catching from Shaangor .
Sample macro using the new soundfx tag... !power {{ --emote|//@{character_name} aims an arrow at a distant foe and fires.// --charid|@{character_id} --format|atwill --name|Shortbow --Attack:|[[ [$Atk] 1d20 + 6 ]] vs AC @{target|AC} --soundfx1|_play|ShortbowDraw _vcontrol,volume:50|ShortbowDraw --?? $Atk &lt; @{target|AC} ?? Miss:|You deal no damage! --?? $Atk &lt; @{target|AC} ?? soundfx2|_play,delay:2|ShortbowMiss --?? $Atk &gt;= @{target|AC} ?? Hit:|[[ 1d8 + 4 ]] piercing damage --?? $Atk &gt;= @{target|AC} ?? soundfx3|_play,delay:2|ShortbowHit }}
So I'm pretty sure the answer here is "no," but is it possible to use a roll $ID as a variable in an inline roll?
1486929373

Edited 1486929650
GM Matt said: So I'm pretty sure the answer here is "no," but is it possible to use a roll $ID as a variable in an inline roll? No, that would require a big re-write of powercards and make it much more resource intensive since it would have to constantly loop through over and over until it found everything it needed to and did all the replacements and then loop through again to do any more replacements needed. That said, if you can fit all the numbers and die rolls into a single roll, you can use [^ID] to display the "variable" elsewhere.
1487323589
Ziechael
Forum Champion
Sheet Author
API Scripter
Having trouble getting the sound fx to work, my main powercards are a bit extreme so I tried some reduced ones to see if it was just my formatting or something but no joy? Running the roll20AM command alone works fine but when using powercards it refuses to fire and even sometimes throws an error: TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined at apiscript.js:1655:50 at eval (eval at (/home/node/d20-api-server/api.js:146:34), :65:16) at Object.publish (eval at (/home/node/d20-api-server/api.js:146:34), :70:8) at /home/node/d20-api-server/api.js:1494:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:461 Definitely running 3.3.0 :/ I've tried reduced use cases like the below and none of the sounds trigger :( !power {{ --emote|//Bob aims an arrow at a distant foe and fires.// --format|atwill --name|Shortbow --Attack:|[[ [$Atk] 1d20 + 6 ]] vs AC 12 --soundfx1|_play|Arrow --?? $Atk &lt; 12 ?? Miss:|You deal no damage! --?? $Atk &lt; 12 ?? soundfx2|_play,delay:2|critmiss --?? $Atk &gt;= 12 ?? Hit:|[[ 1d8 + 4 ]] piercing damage --?? $Atk &gt;= 12 ?? soundfx3|_play,delay:2|Critical Hit }} !power {{ --name|test --rolls|[[ [$att] 1d20 + 50 ]] vs [[ [$tac] 1d4 ]] crit: [[ [$crit] 1d20+50 ]] fumble: [[ [$fbl] 12d2 ]] --?? $att.base == 1 AND $fbl.base == 1 ?? soundfx1|_play,delay:2|critmiss --?? $att.base &gt;= 1 AND $crit.total &gt;= $tac.total ?? soundfx2|_play,delay:2|Critical Hit }}
I had that issue when I started using it and had to completely reload Roll20. Not sure why it worked after that. Also, did you include -players- after the name of the sound in the jukebox? &nbsp;Your critmiss sound effect in the jukebox should look like critmiss-players- unless you create a playlist accessible to players (I didn't test those).
1487325484
Ziechael
Forum Champion
Sheet Author
API Scripter
No joy, refreshed my game, have restarted the API each time to make sure no silent crash is happening and have renamed the tracks to add the -players- suffix but still getting the crash, it sends the powercard prior to the crash however, it's just the sound triggers that seem to be crashing the API :(