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 2 (Thread 2)

Maybe a space before the <br> would solve this.
1430602563
The Aaron
Pro
API Scripter
HoneyBadger said: Maybe a space before the <br> would solve this. Tested it just now. No effect. Taking it out breaks further along. I'm gonna have to guess there is CSS magic afoot.
1430602596
The Aaron
Pro
API Scripter
GenKitty said: I'll have to wait for Powercards to be officially patched; the GM of the game where I noticed this is v e r y leery of API, and I try to keep his interactions with it to a minimum. (You can imagine how much I look forward to script updating/installing being turned into a few button presses! ^_^ ) Of course, that will only work for scripts in the Official Repo... =D
1430603341
Gen Kitty
Forum Champion
Yes, well, that just encourages programmers to get their stuff into the Official Repo. GM's only using Powercards (for me) at the moment. When GroupInit gets updated, that will be his next foray into API. :>
1430605447

Edited 1430607809
vÍnce
Pro
Sheet Author
GenKitty said: Yes, well, that just encourages programmers to get their stuff into the Official Repo. GM's only using Powercards (for me) at the moment. When GroupInit gets updated, that will be his next foray into API. :> GroupInitiatiative is being updated? Cool. What features are going to be added? Thanks Aaron. You're the best. :-P
1430606382
Gen Kitty
Forum Champion
*snicker* SOMEDAY there'll be the option for it to prompt you for the init modifier, instead of pulling it from a character sheet. It is a feture my GM asked for when I first showed this off to him.
I didn't see an option to send to DM only, like a /w gm . . . is that an option? I want my private rolls to look nice too
1430613551

Edited 1430613569
The Aaron
Pro
API Scripter
Add --whisper in your macro, it will go to the GM(s)
1430615714
Gen Kitty
Forum Champion
--whisper|gm for best practices.
NVM found it!
Is [NH] a powercards feature or a standard Roll20 feature? During our game on Friday night, we noticed that most of our macros had stopped working. We eventually tracked it down to the [nh] tag. Removing that from our macros fixed it. The error we got was: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "n" found. This is running on the production server. I haven't updated the powercards scripts since March (2.4.6), or made any changes to the scripts installed in my campaign since then. Has there been a production change which has broken things?
Samuel Penn said: Is [NH] a powercards feature or a standard Roll20 feature? During our game on Friday night, we noticed that most of our macros had stopped working. We eventually tracked it down to the [nh] tag. Removing that from our macros fixed it. The error we got was: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "n" found. This is running on the production server. I haven't updated the powercards scripts since March (2.4.6), or made any changes to the scripts installed in my campaign since then. Has there been a production change which has broken things? [NH] is PowerCards only. I dunno how an older version like that will conflict with the latest updates though.
1430660796
Gen Kitty
Forum Champion
Samuel Penn, you might have had this issue which I reported up-thread: Bug Alert : You need to make sure to put a space between [[ and [NH] or your powercard will fail in a variety of exciting and obscure ways! BAD: [[[NH]3d6+1]] GOOD: [[ [NH]3d6+1]] I'm 99% sure this is related to the nested inline roll change made by Roll20 recently.
1430676195
Gen Kitty
Forum Champion
Grf. The box still isn't highlighting for me when using ro, in 2.4.14 :/
Thanks GenKitty, I've got it working now with your workaround.
GenKitty said: Grf. The box still isn't highlighting for me when using ro, in 2.4.14 :/ I have no plans tomorrow. So I'll try and knock out some of these minor issues. I also recently noticed that multiple die rolls in the same inline roll weren't properly highlighting either. Not sure what changed behind the scenes to cause it though.
Bah... I have no idea how to handle this. If I allow highlighting to carry through on re-rolls, than people using [[1d20ro1]] for Halfling's Luck in 5e will see red and might automatically assume they missed, but on the other side, if you use it for crit confirm [[1d20ro20]] in 3.5/Pathfinder... than it might be assumed to not be a crit. >_<
May 5th, 2015 ~ 5:30 am eastern Version: 2.4.15 Bugfix: Dice rolls with a less than symbol in the expression, such as 1d20cf<3, will show the full tooltip properly now. Minor Update: Justify has been added to inline formatting. Use it the same way as other text alignment. Surround the text to be justified with ~J on either side as below: Example: ~J This text is justified. ~J Minor Update: Emotes now accept left, right, and justify inline formatting (~L, ~R, ~J). Emotes by default are centered. I will try to figure something out for the re-roll once highlighting options. Still not sure how to handle them... and I just had a brilliant idea as I typed this. Instead of red/green... re-roll once should be... a different color! Maybe purple. I dunno yet.
1430851363
Gen Kitty
Forum Champion
Purple works! Though, people using Halfling Luck could write the dice roll as 1d20cf0ro1 . :>
True. I'm currently close to getting conditional statements in PC3 working. Will look at adding purple and getting the multi-roll crit/fail highlighting problem fixed later.
One issue I was having with the script was my players would constantly break the API sandbox trying to figure out how to properly write the macros. This is because the sendChat function returns syntax errors to the sandbox instead of the chat window (like it does if you just typed out a macro). I tried putting a try/catch block around the entire body of the PowerCard.Process function, but that didn't catch all the errors, due to the callback function passed to sendChat getting executed outside the scope of the try/catch block. So you have to put try/catch blocks around the bodies of each of the anonymous function callbacks on lines 256, 261, and 298 as well. This prevents the script from breaking the sandbox when a power card macro results in a syntax parsing error.
Got a conditional statement working in my test version of Powercards 3! Woot. It's very messy though and definitely needs refined. --Attack:|[[ [$id] 1d20]] vs AC --??$id base|total symbol target??Critical Hit:|[[1d6]] extra damage $id is used to identify a roll base|total are used to determine whether you're looking at the base value of the die roll or the total after all modifiers symbol is >=, ==, or <= target is a number you set to compare the base|total too. !power {{ --name|Test --Attack:|[[ [$Atk] 1d20]] vs AC --Hit:|[[1d6+3]] slashing damage --??$Atk base >= 20?? Critical:| [[1d6]] extra damage }} That's a sample of how it currently works, but may or may not be how it ends up working in the finished version 3 of powercards. It is limited to comparing against a single die for base values... so if you did 2d20 or 3d20, it would only compare to the base value of the first die or the total of all three, and that will probably remain a limitation for the time being. I'm trying to get it to work for multiple roll id's too... but that will have to wait til this weekend since I have to go to bed now before work tonight. A multiple comparison for something like D&D 5e may look like this: --??$Atk1 base >= 20 OR $Atk2 base >= 20?? Critical: [[1d6]] extra damage
1430939491

Edited 1430939638
Gen Kitty
Forum Champion
Could I do: --Attack:|[[ [$id]1d20 +whatever +somethingelse]] vs AC ? Will PC3.x have variables we can stuff numbers/dice rolls into? I can already predict GMs not wanting to have to do more math to figure the total damage.
1430942970

Edited 1430944672
GenKitty said: Could I do: --Attack:|[[ [$id]1d20 +whatever +somethingelse]] vs AC ? Will PC3.x have variables we can stuff numbers/dice rolls into? I can already predict GMs not wanting to have to do more math to figure the total damage. Yeah, you can have modifiers to your die rolls. My example just didn't include any. As for variables you can call on later... not yet. I want to get conditionals working first.
Don't you go stealing my purple! :P
Thanks for fixing my last problem with the line breaks! Works much better now. However, after updating to the latest version, i have a new problem. Whenever i am using repeating lines with dice rolls now, such as '!power --name|thing --stuff#2|[[1d20]]', I am getting this error: evalmachine.<anonymous>:452 inlineroll.results.rolls.forEach(function(roll) { ^ TypeError: Cannot read property 'results' of undefined at buildInline (evalmachine.<anonymous>:452:12) at evalmachine.<anonymous>:259:27 at checkFinishedOps (
1431030652

Edited 1431030795
I can't recreate that error. Nevermind... I can on the dev server. Great... >_< ...Riley has gone and changed something about the structure of msg.inlinerolls. I don't have time to fix it right now. Will look in the morning. Leaving for work in twenty minutes.
Okay, thanks, no rush. Your effort is heroic as always. :-)
Bennett S. said: Okay, thanks, no rush. Your effort is heroic as always. :-) Found the problem... not sure what exactly changed between Dev and Prod... but I have a solution. Just don't want to deal with two versions again... so.... somewhere around line 257, look for this: 255 // SEND MODIFIED CARD TO CHAT 256 sendChat("", inlineMultiExps, function(m) { 257 for (var p = 1; p <= inlineMultiRolls.length; p++) { ... and change it to this ... 255 // SEND MODIFIED CARD TO CHAT 256 sendChat("", inlineMultiExps, function(m) { 257 for (var p = 0; p < inlineMultiRolls.length; p++) {
Awesome. Thanks so much.
1431102880
Gen Kitty
Forum Champion
HB, Bennett's issue is just for those playing on the Dev server, yeah?
GenKitty said: HB, Bennett's issue is just for those playing on the Dev server, yeah? Yes, for now. I'm sure that issue will migrate to the production server when Riley adds the nested inline rolls support to the api there as well.
When you say, "... adds the nested inline rolls support to the api..." are you referring to beyond where it is now? I'm only asking because nested inline rolls for the API work on Production. I have them implemented in PowerCard macros on Production right now, and they seem to be working fine.
1431134016
The Aaron
Pro
API Scripter
sendChat('','[[1d2]]',function(ops){ /* ... */ }); ops.inlinerolls is an object in prod, with numeric properties starting at 1: "inlinerolls": { "1": { In dev, it is now an array: "inlinerolls": [ { with numeric indices starting at 0. This change brings it inline with the way that on('chat:message',...) receives the inline rolls. It's actually a good change because it means order is preserved in the array, where it is not guaranteed in the object. Additionally, it means you can use the same code to parse inline rolls from chat messages and sendChat() callbacks. It's unfortunate that it's a breaking change, but of the scripts in the repo, it only breaks one of Brian's (I PM'd him a heads up.) Most scripts pull the /\$\[\[\d+\]\]/ out of the message and extract the number as a reference, and thus are not broken.
I'll be taking another look at how powercards trawls the inlinerolls object/array in pc3 here soon.
1431195853
Gen Kitty
Forum Champion
Bug, 2.4.15, Production: ~L/R/J not being honored in the custom emote. Example Macro: !power --tokenid|@{selected|token_id} --name|Testing --emote|~L //Thrusting her holy symbol into the air, Esme beseeches Desna's divine presence. Within a heartbeat, the symbol pours forth a cloud of butterflies formed from motes of silver light.// ~L I've tried with and without italics, with and without a space between ~L and the text.
1431212175

Edited 1431213645
Bah. It was working for me... >_< Still is working for me...
1431214110

Edited 1431214146
Gen Kitty
Forum Champion
Ignore the error, that was from a different, non-functioning, macro
Ok, figured it out. Your script doesn't need updated. I fixed it directly in your campaign. Will post an update to the gist after I make sure there are no other issues arising from this problem.
1431216915
Gen Kitty
Forum Champion
Thank you! ^_^
May 9th, 2015 ~ 8:00 pm eastern Version: 2.4.15a Bugfix: Fixed an issue with custom emotes not properly aligning with inline formatting.
1431255944
Ziechael
Forum Champion
Sheet Author
API Scripter
Hmm, most likely missing something REALLY obvious here but i've got the following power card (sorry its a big one and a bit of a mess ;) ): !power --emote|@{selected|token_name} rakes at @{target|token_name} with her back claws. --name|Rake --Rake 1|[[1d20]] + [[d0+@{selected|BAB}[BAB] +@{selected|weapon3stat}[Ability] +@{selected|size}[size] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3focus}[Weapon3 Focus] + ?{Flank (1=yes)|0}*2[Flank] +?{Other Att Bonus?|0} ]] vs [[d0+@{target|touchac}]] for [[@{selected|weapon3damage} +@{selected|weapon3damagestat}[Weapon3DamageStat] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3specialize}[Weapon3 Specialization] +?{Other Damage Bonus?|0}[Other Damage Bonus]]] damage! --Rake 1 Critical?|[[1d20+@{selected|BAB}[BAB] +@{selected|weapon3stat}[Ability] +@{selected|size}[size] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3focus}[Weapon3 Focus] + ?{Flank (1=yes)|0}*2[Flank] +?{Other Att Bonus?|0} ]] vs [[d0+@{target|touchac}]] for [[[[(@{selected|weapon3critmult})@{selected|weapon3damage}]] + [[d0+(@{selected|weapon3damagestat}[Weapon3DamageStat] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3specialize}[Weapon3 Specialization])* @{selected|weapon3critmult}]] + [[d0+?{Other Damage Bonus?|0}[Other Damage Bonus]]]]] damage! --Rake 2|[[1d20]] + [[d0+@{selected|BAB}[BAB] +@{selected|weapon3stat}[Ability] +@{selected|size}[size] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3focus}[Weapon3 Focus] + ?{Flank (1=yes)|0}*2[Flank] +?{Other Att Bonus?|0} ]] vs [[d0+@{target|touchac}]] for [[@{selected|weapon3damage} +@{selected|weapon3damagestat}[Weapon3DamageStat] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3specialize}[Weapon3 Specialization] +?{Other Damage Bonus?|0}[Other Damage Bonus]]] damage! --Rake 2 Critical?|[[1d20+@{selected|BAB}[BAB] +@{selected|weapon3stat}[Ability] +@{selected|size}[size] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3focus}[Weapon3 Focus] + ?{Flank (1=yes)|0}*2[Flank] +?{Other Att Bonus?|0} ]] vs [[d0+@{target|touchac}]] for [[[[(@{selected|weapon3critmult})@{selected|weapon3damage}]] + [[d0+(@{selected|weapon3damagestat}[Weapon3DamageStat] +@{selected|weapon3enh}[Weapon3 Enh] +@{selected|weapon3specialize}[Weapon3 Specialization])* @{selected|weapon3critmult}]] + [[d0+?{Other Damage Bonus?|0}[Other Damage Bonus]]]]] damage! --Continued Grapple?|[[1d20+@{selected|str-mod}+@{selected|size}]] vs [[1d20+@{target|str-mod}+@{target|size}]] for [[d0+@{selected|weapon1damage} +@{selected|weapon1damagestat}[Weapon1DamageStat] +@{selected|weapon1enh}[Weapon1 Enh] +@{selected|weapon1specialize}[Weapon1 Specialization] +?{Other Damage Bonus?|0}[Other Damage Bonus] ]] damage! Which i've updated recently to incorporate nested inlines which work fine for my spell damage, just not these attack based ones for some reason?! Ever since i updated it, it has given me the following error: Could not determine result type of: [{"type":"M","expr":4},{"type":"C","text":" + <span style=\"text-align: center; font-size: 100%; font-weight: bold; display: inline-block; min-width: 1.75em; border-radius: 3px; padding: 2px 2px 1px 2px; border: 1px solid; background-color: #88CC88; border-color: #004400; color: #004400;\" title=\"Roll: d0+(floor((17 + 0 + 0)/2-5) +0 +-2)* 2<br>Results: (<span style=' color: #0F0; font-size: 1.25em;'>0</span>) + (floor((17 + 0 + 0) / 2 - 5) + 0 + - 2) * 2 = 2\" class=\"inlinerollresult showtip tipsy fullcrit\">2</span> + <span style=\"text-align: center; font-size: 100%; font-weight: bold; display: inline-block; min-width: 1.75em; border-radius: 3px; padding: 2px 2px 1px 2px; border: 1px solid; background-color: #88CC88; border-color: #004400; color: #004400;\" title=\"Roll: d0+0<br>Results: (<span style=' color: #0F0; font-size: 1.25em;'>0</span>) + 0 = 0\" class=\"inlinerollresult showtip tipsy fullcrit\">0</span>"}]
Macro's like that... I am unable to troubleshoot at all. What you can do is start with part of the macro and gradually add more pieces to it until fails.
1431259361

Edited 1431278281
Ziechael
Forum Champion
Sheet Author
API Scripter
I did do it piece by piece too in order to try and debug it myself... then had to log off so thought i'd appeal for help. I'll break it down a bit more when i get back on later :) thanks [edit] ok, picked it apart bit by bit and each section works in isolation, it is only when the full thing is run that the error listed occurs?! It seems to be having a problem with processing the +-2 and incorporating the d0+0 query result? Genuinely stumped, happy to field any suggestions!
1431278527
Gen Kitty
Forum Champion
I converted all your attribute calls to numbers so I could work on this. Some thoughts as I chew on your macro, Ziechael.... What system are you playing? Why not use the re-roll mechanic to confirm crits? I think I found some errors! In --Rake 1 Critical? you have the following section: for [[[[ (@{selected|weapon3critmult})@{selected|weapon3damage} ]] I put a * in there: for [[[[ (@{selected|weapon3critmult})*@{selected|weapon3damage} ]] Oh look, you did it again in Rake 2 Critical, just as I semi-expected Now here's the really WEIRD bit. I can make Rake 1 work, or I can make Rake 2 work. I can't make them BOTH work in the same macro. I keep getting: SyntaxError: Expected "[" or [ |\t] but "<" found. Some final thoughts: Your macro is a little more cumbersome than it needs to be. Try this on for size: (No, I didn't put your attribute calls back, but I did leave all your inline labels) !power {{ --emote|@{selected|token_name} rakes at @{target|token_name} with her back claws. --name|Rake --Rake#2:|[[ 1d20ro20 +1[BAB] +2[Ability] +0[size] +1[Weapon3 Enh] +0[Weapon3 Focus] + ?{Flank (1=yes)|0}*2[Flank] +?{Other Att Bonus?|0} ]] vs [[@{target|ac}]] for [[ [[(3)*1d8]] + [[d0+(3[Weapon3DamageStat] +1[Weapon3 Enh] +0[Weapon3 Specialization])* 3]] + [[d0+?{Other Damage Bonus?|0}[Other Damage Bonus] ]] ]] damage! --Continued Grapple?|[[1d20+1+1]] vs [[1d20+1+1]] for [[d0+1 +1[Weapon1DamageStat] +1[Weapon1 Enh] +1[Weapon1 Specialization] +?{Other Damage Bonus?|0}[Other Damage Bonus] ]] damage! }} Whitespace is your friend, use it to set off your nestings. I hope all of this is a help to you!
Didn't someone find out that at like 90'ish elements Roll20 crapped out?
PowerCards 3 is 99% done! Just need to figure out why inline roll highlighting isn't working.
1431335990
Ziechael
Forum Champion
Sheet Author
API Scripter
GenKitty said: I converted all your attribute calls to numbers so I could work on this. Some thoughts as I chew on your macro, Ziechael.... What system are you playing? Why not use the re-roll mechanic to confirm crits? I think I found some errors! In --Rake 1 Critical? you have the following section: for [[[[ (@{selected|weapon3critmult})@{selected|weapon3damage} ]] I put a * in there: for [[[[ (@{selected|weapon3critmult})*@{selected|weapon3damage} ]] Oh look, you did it again in Rake 2 Critical, just as I semi-expected Now here's the really WEIRD bit. I can make Rake 1 work, or I can make Rake 2 work. I can't make them BOTH work in the same macro. I keep getting: SyntaxError: Expected "[" or [ |\t] but "<" found. Some final thoughts: Your macro is a little more cumbersome than it needs to be. Try this on for size: (No, I didn't put your attribute calls back, but I did leave all your inline labels) !power {{ --emote|@{selected|token_name} rakes at @{target|token_name} with her back claws. --name|Rake --Rake#2:|[[ 1d20ro20 +1[BAB] +2[Ability] +0[size] +1[Weapon3 Enh] +0[Weapon3 Focus] + ?{Flank (1=yes)|0}*2[Flank] +?{Other Att Bonus?|0} ]] vs [[@{target|ac}]] for [[ [[(3)*1d8]] + [[d0+(3[Weapon3DamageStat] +1[Weapon3 Enh] +0[Weapon3 Specialization])* 3]] + [[d0+?{Other Damage Bonus?|0}[Other Damage Bonus] ]] ]] damage! --Continued Grapple?|[[1d20+1+1]] vs [[1d20+1+1]] for [[d0+1 +1[Weapon1DamageStat] +1[Weapon1 Enh] +1[Weapon1 Specialization] +?{Other Damage Bonus?|0}[Other Damage Bonus] ]] damage! }} Whitespace is your friend, use it to set off your nestings. I hope all of this is a help to you! Thanks for taking a look GenKitty, I should have mentioned that I'm using Diana's 3.5 character sheet (along with some home-brew rule calls) and that most of this is built from her original attack macros which i've ruthlessly butchered for my own diabolical needs. Therefore, (@{selected|weapon3critmult})@{selected|weapon3damage} needs to stay as it is, i use weapon n damage to house the die to roll, so the above works out as 3d6 for example. You are right though that i really should not use massive blocks of text, i'm just stuck in my ways lol. The confusing thing for me is that this worked fine before i put in the nested inline rolls?!? I may just have to revert it to the original slightly messier one (thats right, this is the NEAT version!). I also have the same effect on another macro which is almost twice the size, but again that worked fine before i nested some of the rolls. I did notice that you put the whole PC in {{ }} which is something i've never done... does that have an effect? (i try to keep up but still build my PC's the same way i did when PC2 was first released... : /
Ziechael said: I did notice that you put the whole PC in {{ }} which is something i've never done... does that have an effect? (i try to keep up but still build my PC's the same way i did when PC2 was first released... : / Thanks to TheAaron, he figured out a way to use the roll template stuff to be able to put power card tags on multiple lines and still work. !power {{ --name|Test --Attack|[[1d20]] }} ... will do the same thing as ... !power --name|Test --Attack|[[1d20]] ... and it is much easier to read and write.
1431338011
Ziechael
Forum Champion
Sheet Author
API Scripter
Oh right, i see now... that certainly helps me to write my cards in a much cleaner way from now on (and should aid debugging!). Thanks for explaining :)