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

1420210612
Speaking of tinkering... I totally did not know this works, but GenKitty pointed it out to me offhand. !power --name|Death Save [[1d20]] Kinda cool! ^_^
1420210761
GenKitty said: HB, you wonderful fellow, you put all the fonts in one place for me to edit :> Here, have cookies! It was necessary to turn them into variables like that for --titlefont and such to work. But thanks! :)
1420212762

Edited 1420212864
So, I am attempting to use this script with the 5e character sheet abilities. I came up with this script for attacks (based off the embeded attack scripts: !power --emote|@{selected|token_name} slashes at his foe with a @{selected|meleeweaponname1} --format|atwill --name|Melee Attack --leftsub|Action --rightsub|Reach 5 ft. --Attack|[[1d20 + @{selected|meleetohit1} [To Hit] + (@{selected|global_melee_attack_bonus}) [Active Melee Attack Bonus] ]] | [[1d20 + @{selected|meleetohit1} [To Hit] + (@{selected|global_melee_attack_bonus}) [Active Melee Attack Bonus] ]] vs AC [[@{Target|AC_calc}]] --Hit| [[@{selected|meleedmg1} [Base damage] + @{selected|meleedmgbonus1} [Damage Bonus] + (@{selected|global_melee_damage_bonus}) [Active Melee Damage Bonus] + 0d0 [Bugfix 0] ]] @{selected|meleedmgtype1} damage (if a crit add an extra [[@{selected|meleedmg1}]]) It is giving me an error of: TypeError: Cannot read property 'atwill' of undefined at Object.PowerCard.Process
1420213035
Did you or your GM create a handout as required to make the --format tag work?
1420213186

Edited 1420213250
Yes, I did. I named it as you did in the image in the first post. I have tried: atwill: --txcolor|#FFF --bgcolor|#040 and atwill: --txcolor|#FFFFFF --bgcolor|#004400 and got the same error each time.
1420213319
The name of the handout is specifically PowerCard Formats ?
Haha I plurized PowerCards. Fixed. Now I am getting a new error: TypeError: Cannot call method 'forEach' of undefined at processRoll (evalmachine.:2044:16) at evalmachine.:1957:16 at Array.forEach (native) at buildInline (evalmachine.:1956:27) at Object.PowerCard.Process (evalmachine.:1811:16) at evalmachine.:1637:59 at eval ( For clarity, I have this in my handout: atwill: --txcolor|#FFFFFF --bgcolor|#004400 encounter: --txcolor|#FFFFFF --bgcolor|#440000 daily: --txcolor|#FFFFFF --bgcolor|#444444 item: --txcolor|#FFFFFF --bgcolor|#e58900 recharge: --txcolor|#FFFFFF --bgcolor|#000044
1420213993
My guess is that one or more of your @{attributes} are non-existent on the character sheet.
Thats odd, because I copied and pasted it from a macro I have been using for months. Ill go through each and see if I can find the culprit.
1420216285
Josh said: Thats odd, because I copied and pasted it from a macro I have been using for months. Ill go through each and see if I can find the culprit. That's my guess... since processRoll only specifically deals with inline rolls. It's hard for me to bugcheck macros like that, since there are so many character specific attribute calls in them. Not without being invited to the campaign and promoted to GM.
1420216650
The Aaron
Forum Champion
API Scripter
Here is his command with just monotonically increasing numbers replacing the attribute references: !power --emote|1 slashes at his foe with a 2 --format|atwill --name|Melee Attack --leftsub|Action --rightsub|Reach 5 ft. --Attack|[[1d20 + 3 [To Hit] + (4) [Active Melee Attack Bonus] ]] | [[1d20 + 5 [To Hit] + (6) [Active Melee Attack Bonus] ]] vs AC [[7]] --Hit| [[8 [Base damage] + 9 [Damage Bonus] + (10) [Active Melee Damage Bonus] + 0d0 [Bugfix 0] ]] 11 damage (if a crit add an extra [[12]]) Should let you test the format of the command without the characters.
1420216801
The Aaron
Forum Champion
API Scripter
There is a space after --Hit| , could that cause the issue? I know you mention that as a bad tag in the insturctions.
1420217074
The Aaron said: Here is his command with just monotonically increasing numbers replacing the attribute references: !power --emote|1 slashes at his foe with a 2 --format|atwill --name|Melee Attack --leftsub|Action --rightsub|Reach 5 ft. --Attack|[[1d20 + 3 [To Hit] + (4) [Active Melee Attack Bonus] ]] | [[1d20 + 5 [To Hit] + (6) [Active Melee Attack Bonus] ]] vs AC [[7]] --Hit| [[8 [Base damage] + 9 [Damage Bonus] + (10) [Active Melee Damage Bonus] + 0d0 [Bugfix 0] ]] 11 damage (if a crit add an extra [[12]]) Should let you test the format of the command without the characters. It is crapping out on the 0d0 and 0d1 calls. >_<
1420217205
The Aaron said: There is a space after --Hit| , could that cause the issue? I know you mention that as a bad tag in the insturctions. Nah, I tried !power --name|Test [[0d0]] and it just went to crap.
1420217413

Edited 1420217773
Hrm, it is also crapping out on math only inline rolls with labels, i.e. [[1 + 2 [Dex Mod] + 3]] [[1 + 2 + 3]] works though. This is a bug with Roll20 and not PowerCards. [[ 1 + 2 [Label] ]] > Fails in chat... [[ 1 + 2 ]] > Shows up as [3] [[0d1 + 1 + 2 [Label] ]] > Shows up as [3] edit - Well, partially a bug with PowerCards. Something with the inlineRoll builder and processRoll is having issues with 0d0 or 0d1 and that's the workaround for math only rolls with labels in Roll20. Bleh. Will have to work on this later. Trying to get the --target_list done.
1420217769
The Aaron
Forum Champion
API Scripter
The issue seems to be this roll object: { . "dice": 0, . "sides": 0, . "type": "R" } looking at how it gets passed in there...
1420217822

Edited 1420217841
The Aaron said: The issue seems to be this roll object: { . "dice": 0, . "sides": 0, . "type": "R" } looking at how it gets passed in there... Yeah. Brian did most of the work with the roll parsing as my half-assed hacks at it early on were not good enough. A lot of it is still greek to me in that area, lol.
1420217974
The Aaron
Forum Champion
API Scripter
Oh.. it's the 0d0. If you change line 421 to this: _.each(roll.results,function(result) { It happily ignores when that's not an array.
1420218084
The Aaron
Forum Champion
API Scripter
I'd suggestion changing all your .forEach() calls to _.each( [potential array], function(){} ). It will protect your code against having bad arrays like that.
1420218427
The Aaron
Forum Champion
API Scripter
Also, you might want to change line 79: var PowerCard_Formats = ( state.PowerCard_Formats && state.PowerCard_Formats[PowerCard.format] !== undefined) ? state.PowerCard_Formats[PowerCard.format].split("--") : ["txcolor|#FFF", "bgcolor|#040", "titlefont|Georgia", "subtitlefont|Tahoma"]; If you don't have a PowerCard Formats note, the script won't have created the entry in the state, and attempting to use it will cause a crash. An edge case, to be sure, but something people might hit. (I did!)
1420218506
The Aaron said: I'd suggestion changing all your .forEach() calls to _.each( [potential array], function(){} ). It will protect your code against having bad arrays like that. Cool... that worked. Easy fix. The underscore website isn't very helpful to me. I've tried reading it, but pretty much all my "skill" with javascript is gleaned from Qbasic, maptool macro stuff, and google.
I removed the 0d0 and it worked fine. I think the original script on the character sheet keeps it due to macro reactions with the css in character sheets. Thats solved. Thanks team!
1420219712
The Aaron
Forum Champion
API Scripter
HoneyBadger said: Cool... that worked. Easy fix. The underscore website isn't very helpful to me. I've tried reading it, but pretty much all my "skill" with javascript is gleaned from Qbasic, maptool macro stuff, and google. Underscore is really powerful, but I agree that their site is more of a reference manual than a tutorial! It took me forever to figure out what the heck their _.chain() function did, but now it's pretty much my go-to hammer. :) I should probably write some cookbook type examples on the wiki for underscore...
1420220256
Lithl
Pro
Sheet Author
API Scripter
The Aaron said: I should probably write some cookbook type examples on the wiki for underscore... Have at it ! =)
1420223720
The Aaron
Forum Champion
API Scripter
ha!
1420229297

Edited 1420229324
Gen Kitty
Forum Champion
0d0 is the Roll20 Canonical answer to making inline labels in math-only rolls work correctly, so it is helpful if the powercard code supports it.
1420243886
Target Info Charms are almost done... trying to figure out a way to get them to show up as inline rolls as well, as a formatting option. Right now, they cannot. Will work on this later... goin' to bed now.
1420244507
Gen Kitty
Forum Champion
WOO HOO! YES! YEE HAW!
I've tried the following: [[ [HR@{target|ArmorClass}] 1d20]] It didn't work and I didn't expect it would work either, but the idea is great. Imagine that your attackroll will be highlighted green when you roll equal or above the targets armor class and red below.
1420254315

Edited 1420255804
Muse
Pro
I'm getting: Unexpected token * for any use of the script, even a simple !power --name|Test Nevermind, was a conflict with a different script, deleting the comments fixed it but it's odd that it works find with the comments in place without powercards enabled.
1420262626
Lithl
Pro
Sheet Author
API Scripter
DRB GM said: I'm getting: Unexpected token * for any use of the script, even a simple !power --name|Test Nevermind, was a conflict with a different script, deleting the comments fixed it but it's odd that it works find with the comments in place without powercards enabled. Was it a multi-line comment at the end of the other script or something? All scripts get copied into one mega-script when you run the game.
1420263494
Bo KH said: I've tried the following: [[ [HR@{target|ArmorClass}] 1d20]] It didn't work and I didn't expect it would work either, but the idea is great. Imagine that your attackroll will be highlighted green when you roll equal or above the targets armor class and red below. The inline highlighting tags (HR, LR, and CR) do not do any kind of math or attribute calls. It would require a lot of nested sendchats or re-creation of the entire dice parser to make that work.
1420274313
Progress!! The troll reflex attribute is 10 + @{Dex Mod} + @{Half Level} just for testing... and it works. You can also include dice rolls in their attributes, but no roll queries. So any modifiers to defense should be done as an attack roll modifier. So if your target has -2 ac... +2 to attack instead for that roll. Still working on this to make sure it's robust enough to put out there though.
1420282215
vÍnce
Pro
Sheet Author
Question: Is the "PowerCard Formats" handout only used for formatting individual tags added to a powercard, or can I use it to set the global format as well? I guess I'm confused on how to best use the format handout. I don't really need to create special formatting for each tag and I'm not sure if I just need to change the settings within the script itself like I've done in the past or create a "default" tag in the handout and add "--format|default" to all my macros.
1420282426

Edited 1420282447
The handout is just for setting options for the --format tag. However, as you mentioned, you could just create a default: entry in the handout and add --format|default to all your macros and your script you use to make them.
1420288510

Edited 1420427935
Updates & Bugfixes: Jan 3rd, 2014 ~ 7:45 am eastern Version : 2.2.0 Update : --target_list replaced --targets and has significantly more features (see op) Added new config option... SUPPRESS_INLINE_CHARMS ...setting this to true turns all attribute charms into plain text. This part of the new feature will change to make this more flexible instead of all or nothing. Token charms are all plain text currently regardless of this setting. Bugfix : Implementation of [CR#|#] made [HR] and [LR] stop working properly. Bugfix : Using --whisper with custom emotes broke the emote badly. Bugfix : Zero dice rolls (0d0, 0d1, etc) broke the script. New Feature ~ Target Info Charms This new feature lets you grab info from a character sheet or token by using --target_list|@{target|1st Target|token_id} | @{target|2nd Target|token_id} | etc to create the list of targets and then adding target info charms into the content of your powercard such as %%token_name%% to get the name of the token. The types of charms are broken down into two categories: token charms and attribute charms. Token charms area set list that grab information like bar values and the name of the token. Attribute charms can be any attribute on a character sheet and they are case sensitive. AC is not the same as aC, Ac, or ac. Finally... and this is very important ...all charms referring to a target must be in the same tag. You cannot have charms split between tags. If you want to create a kind of stat sheet, use line breaks ^^ to create new lines. Good Examples !power --name|Single Target Attack --target_list|@{target| |token_id} --Attack|[[1d20+5]] | [[1d20+5]] vs %%AC%% Armor Class (%%token_name%%) --Hit|[[1d8+3]] slashing damage !power --name|Scorching Burst | Nine Targets --target_list|@{target|1st|token_id} | @{target|2nd|token_id} | @{target|3rd|token_id} | @{target|4th|token_id} | @{target|5th|token_id} | @{target|6th|token_id} | @{target|7th|token_id} | @{target|8th|token_id} | @{target|9th|token_id} --Attack#?{Number of targets|1}|[[1d20+5]] vs %%Reflex%% Reflex (%%token_name%%) --Hit|[[1d8+3]] fire damage For a multi-attack power like Scorching Burst in D&D 4e, you create the macro as above and just click nine times and then when the pop up for number of targets appears, type in the actual number of targets in the area and hit enter. The script will ignore the rest of the targets in the list. For example, in the snip below... I clicked nine tokens pretty quickly. Only the first four mattered since those were my actual targets. Then I typed in the number of targets and hit enter when the pop up appeared. !power --name|Stats --target_list|@{target|1st Target|token_id} --Target|%%token_name%% ^^ **Hit Points:** %%bar3%%/%%bar3_max%% ^^ **Defenses:** AC %%AC%%, Fort %%Fortitude%%, Reflex %%Reflex%%, Will %%Will%% Bad Example !power --name|Bad Example --target_list|@{target| |token_id} --Target|%%token_name%% --Attack|[[1d20+5]] | [[1d20+5]] vs %%AC%% Armor Class --Hit|[[1d8+3]] slashing damage to %%token_name%% In the example above, the %%AC%% and second %%token_name%% charms would not be replaced with the proper info. Token Charms %%token_name%% %%bar1%% %%bar1_max%% %%bar2%% %%bar2_max%% %%bar3%% %%bar3_max%% Sample Attribute Charms %%Strength%% %%Strength Mod%% %%Fortitude% %%Reflex%% %%Will%% %%HP%% %%Hit Points%%
1420289732
Minor Update: Jan 3rd, 2014 ~ 7:55 am eastern Version: 2.2.1 Minor Update: Moved rounded corners setting to the PowerCard object so that you can set round/square per card using --corners|#
1420300537
Gen Kitty
Forum Champion
*big eyes* *runs off to test this* *also notices she can have square cards regardless of GM settings and eyes go just that little bit wider**
1420301077
Gen Kitty
Forum Champion
Bug: Formatting broken ReferenceError: obj is not defined at doInlineFormatting (evalmachine.<anonymous>:1797:28) at evalmachine.<anonymous>:1652:13 at Array.forEach (native) at Object.PowerCard.Process (evalmachine.<anonymous>:1650:7) at evalmachine.<anonymous>:1514:59 at eval (
1420301840
Gen Kitty
Forum Champion
Bug: attack array consistently skips first two targets when doing a multiattack. Below is my test macro. Skips targets 1 & 2. If I use more than N-2 targets for the attack array, I get %%Ref%% %%token_name%% printed instead on those lines. !power --name|Scorching Burst --AoE|Close Burst 1 --VS|Reflex --target_list|@{target|1st|token_id} | @{target|2nd|token_id} | @{target|3rd|token_id} | @{target|4th|token_id} | @{target|5th|token_id} | @{target|6th|token_id} | @{target|7th|token_id} | @{target|8th|token_id} | @{target|9th|token_id} --Target#?{Number of targets|1}|[[1d20+5]] vs %%Ref%% %%token_name%% --Hit|[[1d8+3]] fire damage
1420302128
Gen Kitty
Forum Champion
Good news: --corners, --emote plus --whisper, and 0d0 work as advertised! ^_^
1420312141
vÍnce
Pro
Sheet Author
A cool thing I discovered on powercard version 1.x that works even better on version 2.x; nested !power . You can have multiple powercards launch within the same macro. In version 1.x I could launch just 2, and the second card would only post info to a header. With v2.x I can nest as many cards as I want and they are completely formatted! If you are utilizing your sheet's html to insert !power into the sheet's macros, or an external script to create token ability macros, you just need to use " \n !power" to introduce a carriage return. When adding additional !power and/or other scripts, just manually add a carriage return for each new script. When using an attack macro with @{target} I like to have one "attack" card that everyone can see and another "target" card just for the GM (--whisper|gm).
1420312830
vÍnce
Pro
Sheet Author
Note to self: the diamond graphic used between --leftsub|, --rightsub| gets replaced with " ♦ " when copying from the github raw . So don't.
1420318173
The Aaron
Forum Champion
API Scripter
Vince said: Note to self: the diamond graphic used between --leftsub|, --rightsub| gets replaced with " ♦ " when copying from the github raw . So don't. Yeah, Stephen had the same issues with UTF-8 characters in one of his scripts.
1420318593
The Aaron
Forum Champion
API Scripter
HB, you could replace the end of line 125 with: : ' &'+'#x2666; ' ; and it wouldn't be an issue.
1420318973

Edited 1420318994
I get an Unexpected identifier when I use the script (2.2.1) on the dev server.
1420321150
GenKitty said: Bug: attack array consistently skips first two targets when doing a multiattack. Below is my test macro. Skips targets 1 & 2. If I use more than N-2 targets for the attack array, I get %%Ref%% %%token_name%% printed instead on those lines. !power --name|Scorching Burst --AoE|Close Burst 1 --VS|Reflex --target_list|@{target|1st|token_id} | @{target|2nd|token_id} | @{target|3rd|token_id} | @{target|4th|token_id} | @{target|5th|token_id} | @{target|6th|token_id} | @{target|7th|token_id} | @{target|8th|token_id} | @{target|9th|token_id} --Target#?{Number of targets|1}|[[1d20+5]] vs %%Ref%% %%token_name%% --Hit|[[1d8+3]] fire damage That is weird... my scorching burst power that is pretty much the same works properly. Bo KH said: I get an Unexpected identifier when I use the script (2.2.1) on the dev server. I don't know what to tell you. It works fine for me. If you're running some other script, it could be a combination of comments or something that others have had an issue with.
1420321386
Ah, I see what is wrong... it's removing the names from the target_list even though it didn't actually use them. It'll be a quick fix.
1420321906
Quick Fix for Target List Bug: if (PowerCard.target_list !== undefined && Content.indexOf("%%") !== -1) { Replace line 154 with that line. I will post an update to the OP soon.
1420322298
Bug Fix: Jan 3rd, 2014 ~ 5:00 pm eastern Version: 2.2.2 Bugfix: Key content loop was removing targets from the target list even though it wasn't doing anything with them yet. (GenKitty) Bugfix: Copying script from gist resulted in html entities issues. (Vince/The Aaron)