PowerCards 3
Current One-Click Install Version : 3.8.8 Current Development Version:
3.8.10 Dev Source Link: <a href="https://gist.github.com/kjaegers/7fd81c55517014704b9fe3986660341c" rel="nofollow">https://gist.github.com/kjaegers/7fd81c55517014704b9fe3986660341c</a> PCM Helper Development Version: 1.0 .2 PCM Helper Source Link: <a href="https://gist.github.com/kjaegers/d73e276e3a5f5b56e197abba441dc0d2" rel="nofollow">https://gist.github.com/kjaegers/d73e276e3a5f5b56e197abba441dc0d2</a> Previous Thread: <a href="https://app.roll20.net/forum/post/4285059/script-powercards-3-thread-4/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/4285059/script-powercards-3-thread-4/?pagenum=1</a>
Attribute-Based Tags Demo Video: <a href="https://www.youtube.com/watch?v=JwUkdO-F3LQ" rel="nofollow">https://www.youtube.com/watch?v=JwUkdO-F3LQ</a> Templates and Replacements Video: <a href="https://www.youtube.com/watch?v=ESfovaVMddw" rel="nofollow">https://www.youtube.com/watch?v=ESfovaVMddw</a> If you wish to support PowerCards development, there is now a Patreon account set up : <a href="https://www.patreon.com/KurtJaegers" rel="nofollow">https://www.patreon.com/KurtJaegers</a> . Of course, this is completely optional and you should feel in no way obligated to do so. NOTE: This post had grown too large to edit, so I've trimmed out the tag descriptions and most of the table-like structures. For documentation on these options, please visit the PowerCards Wiki Page. I will also keep this post updated with the current change logs from development. See this post : <a href="https://app.roll20.net/forum/post/6264588/script-powercards-3-thread-5/?pageforid=6577204#post-6577204" rel="nofollow">https://app.roll20.net/forum/post/6264588/script-powercards-3-thread-5/?pageforid=6577204#post-6577204</a> for information about manually patching PowerCards to support the 7/11/2018 update to Roll20 to allow your existing macros to work while you update them over time. --- 2018-11-13 Verison 3.8.8 Added the --replaceattrlist tag. See Wiki for details. Cleaned up extraneous log commands that were resulting in clutter in the API console. Updated getSpellMacro function (non-breaking). If the spell macro attribute being referenced begins with a #, it will be assumed to be a global macro. If not, it will be assumed to be an on-character macro and will have the character's ID prepended in the command button. 2018-07-21 Version 3.8.1 You can now use !power, !powercard, or !powercards (with any variation of upper/lower case) to trigger PowerCards. Previously, only !power (all lower case) was allowed. New tag : --replaceattrs creates a number of replacement pairs for a particular character. See this section of the wiki for details. new tag : --replacespell creates a number of replacement pairs for a given spell. See this section of the wiki for details. 2018-07-15 Version 3.8.0 New tag --inlinereplace allows you to define replacement sets
without a handout. The format is the same as if you had added the line
from a replacement handout into the card (for example,
--inlinereplace|Hi|Hello;Bye|Goodbye will produce ~Hi$ and ~Bye$
replacement keys with values of Hello and Goodbye respectively. As with
standard replacements, these are processed before any other part of the
card, so they can be used in rolls, templates, comparisons, etc. You can
use a roll query to assign the value via the chat server as well. Any roll using replacements (of any type) needs to be hidden from the chat server (see the next bullet) and use a Roll ID. You
can now use [#[ and ]#] in place of [[ and ]] to prevent the chat
server from processing a roll and avoid using replacement variables for
[[ and ]]. In these cases, you need to use a roll ID in the roll. For
example, --damage|You deal [[ [$dmg] 1d6 ]] and --damage|You deal [#[
[$dmg] 1d6 ]#] are equivalent, but the chat server won't try to process
the second one. Multiple replacement, format, and template
handouts are now available. As long as your handout name starts with
"PowerCard Replacements", "PowerCard Templates", or "PowerCard Formats",
the handout will be processed and cumulatively added to the appropriate
list. Read order is not guaranteed, so it is best to not have
duplicates between handouts. Consolidated code for processing handouts to speed things up a little. Not really noticeable, but worth doing anyway. Handout
processing now strips out non-breaking spaces (&nbsp;) and
paragraph starts (<p>) sequences, and converts paragraph end
(</p>) sequences to line breaks (<br>) in order to work
around issues introduced by the new editor. 2018-07-07 Version 3.7.9 Sandbox protection code. The first part of my effort to implement
protection into the PowerCards code base to try to prevent the API
Sandbox from being crashed by issues with cards, templates, and
replacements. Many of these are uncommon, but adding code the prevent
them will help reduce frustration when something goes awry during a
game. Added code to the format handout processor to attempt to
compensate for oddness introduced by the latest Roll20 update that
replaced the text editor. The format processor now strips out all HTML
code from the handout lines while processing them. Exposed the
Process function so PowerCards can be used by other API scripts (Such as
The Aaron's PCPP (PowerCard Pre Processor)). The external function name
is PowerCards.Process 2018-06-29 Version 3.7.8 Updated --replacement to accept multiple replacement sets on a single line, separated by semicolons (;) Modified the order that template and replacement tags are processed in to enable additional features Templates now support execution-time optional tags. Prefixing a tag with something in [square brackets] will trigger this evaluation. If the content of the brackets is a simple non-empty value, the tag will be displayed. If they are empty, the tag will not be added to the card. If the contents of the brackets are an evaluatable javascript expression, the tag will be added if the expression is true. 2018-06-18 Version 3.7.7 (See the full post on Page 4 for examples and usage info) -Now supporting templates
and replacement values! This is a pretty major update, and will stay on
the development GIST for a while before moving to One-Click. PowerCards
now supports two new reserved tags: --template
: Imports the tags defined in a handout called "PowerCard Templates".
Templates are named sets of tags that can include parameters that get
passed in by the content of the --template tag when the PowerCard is
evaluated. The format for the Templates handout is similar to the
PowerCard Formats handout: One line per template (they can wrap around
as much as you like, but lines are ended with a carriage return).
Templates start with a name, followed by a colon. Then a list of tags
denoted by the standard -- prefix. A template can allow for value
substitution by including ~#! in the line, where # is a parameter number
starting at 0 (so, ~0! is the first parameter, ~1! is the second, and
so on). When a template tag is used in a PowerCard macro, it is in the format: --template|TemplateName|Parameter0;Parameter1;Parameter2
@{} notation (like @{selected|character_name}, etc) is supported when
calling the template, but not within the template itself (the API
doesn't have the necessary information to deal with that notation as it
is done by the chat server, which just passes IDs). The position of the template tag in the PowerCard is preserved, so other lines can appear before or after it. --replacement
: Basically the opposite of templates. Another new handout called
"PowerCard Replacements" can define replacement sets by name, followed
by a colon, followed by a list of replacement keys and values. Key/Value
pairs are separated from each other with semicolons, and keys and
values themselves are separated by vertical bars (|). A
replacement tag will look at all of the other tags in the PowerCard and
replace the keys with the given values. Keys in a PowerCard are denoted
with ~keyname$ notation (start with a ~ and end with a $).
Both --template and --replacement can be used multiple times with the
"Same Tag" modifier (--template*1, --template*2, etc). They can also be
used together. All --template lines are processed first, then all
--replacement lines, so values passed in as parameters to templates
could be specified by replacement entries. Multiple uses of the
replacement tag are cumulative, with earliest definition of a
replacement key being the one that will get used. 2018-06-09 - Version 3.7.6 - Fixed a sandbox crash when using the [TRKR] roll modifier with an invalid --charid specified. - Added new formatting tags for creating HTML tables. These are (compared to other PowerCards formatting commands) a bit more complicated to use: The table MUST be properly formatted (opening and closing all tags) and MUST be contained within a single PowerCards tag. The formatting tags are [TTB] and [TTE] to open and close a table (<table> and </table>), [TRB] and [TRE] to open and close a table row (<tr> and </tr>) and [TDB] and [TDE] to open and close a table cell (<td> and </td>). You can place modifiers to the HTML tags inside the square brackets (alignment, coloring, etc). Here is an example: !power {{
--name|Testing
--!Hello|~C[TTB 'width=100%' 'bgcolor=Black'][TRB][TDB align=left colspan=10]**$$#fff|Male Dwarf$$**[TDE][TRE]
[TRB][TDB width='10%']**$$#fff|B$$**[TDE][TDB width='10%']**$$#fff|A$$**[TDE][TDB width='10%']**$$#fff|R$$**[TDE][TDB width='10%']**$$#fff|S$$**[TDE][TDB width='10%']**$$#fff|W$$**[TDE][TDB width='10%']**$$#fff|L$$**[TDE][TDB width='10%']**$$#fff|I$$**[TDE][TDB width='10%']**$$#fff|C$$**[TDE][TDB width='10%']**$$#fff|EDG$$**[TDE][TDB width='10%']**$$#fff|ESS$$**[TDE][TRE]
[TRB 'bgcolor=#444444'][TDB width='10%']**$$#fff|5(6)$$**[TDE][TDB width='10%']**$$#fff|4$$**[TDE][TDB width='10%']**$$#fff|4(5)$$**[TDE][TDB width='10%']**$$#fff|6$$**[TDE][TDB width='10%']**$$#fff|6$$**[TDE][TDB width='10%']**$$#fff|5$$**[TDE][TDB width='10%']**$$#fff|5$$**[TDE][TDB width='10%']**$$#fff|3$$**[TDE][TDB width='10%']**$$#fff|2$$**[TDE][TDB width='10%']**$$#fff|4.3$$**[TDE][TRE][TTE]~C
}}
which will produce the following: 2018-05-15 - Version 3.7.5 - The action list tags (--npc_action_list, etc) use a different method of detection repeating sections on character sheets (thanks to Jackob's post in another thread!). They will no longer display mislabeled buttons when used on a character sheet that has had its repeating sections reordered. 2018-05-12 - Version 3.7.4 - The --api_ tag will now process inline formatting before sending the API command. This allows the use of RollIDs in API commands, providing a way to use calculated/rolled values in API calls. It might also cause trouble for existing PowerCards using the --api_ tag if any of the inline formatting characters are used in the API string (likely uncommon, but still possible). 2018-05-06 - Version 3.7.3 - Updated the --npc_action_list and --npc_legendaryaction_list tags to check for attributes on the character sheet in the format "action_$0_macro" and "action-l_$0_macro" (with $0 being replaced by the appropriate repeating action index). If a matching value is present for an action, the content of the attribute will be used instead of the default OGL action button, which allows you to specifying a macro to use instead of the standard action (include the #). With the correct macros set up, this allows a summary PowerCard to create buttons that call other PowerCards if defined, with a fallback to the default button format. Specifying "NONE" as the value of the associated attribute will prevent a button from being created for that action at all (attr-based or fallback). - Added --ogl_pc_attack_list tag to generate a list of repeating attack buttons for PCs using the OGL sheet - Updated tags that generate buttons for actions, legendary actions, etc to use the actor's character ID instead of @{selected} so it is not necessary to maintain the token as the selected token in order to use the abilitiy from the power card. - Updated the _list and _summary tags to display a horizontal rule and title if they contain data, and nothing if they don't. This allows for a single macro to be used for PCs and NPCs if desired. 2018-04-14 - Version 3.7.2 - Corrected bugs with the status
icon system (specifying a status that did not exist would crash the
sandbox). This system looks to me like it was never fully implemented,
so I'll be taking a more in-depth look at it in the near future. -
Added support for Custom FX in the --vfx_opt and --vfxattr commands.
Interestingly, since I need to calculate the angle manually, they aim
more accurately than the default effects. - Added getAttrOrEmptyString and outputIfNotEmpty utility functions. -
Added getRepeatingCount function to retrieve the number of repeating
item entries to prevent spamming the sandbox log with "You tried to
access a repeating section..." errors. They didn't hurt anything, but I
would rather not clutter the log. - Rewrote the _list and _summary tag code to utilize getRepeatingCount. This makes them sorter and cleans things up a bit. -
Moved the check for setting TargetToken outside of the emote section,
so we no longer need an emote to use targeted --vfxattr effects. - Modified last updated date format to simply updating the date - Bugfix: --npc_attribute_summary now shows (0) instead of () if an attribute modifier is 0 -
First cut at limited multi-sheet support via an attribute translation
lookup table. Spell Slots and attributes summary should work for 5E OGL
and 5E Shaped now. More work to do on this. 2018-04-10 - Version 3.7.1 - Updated script to be enclosed in an anonymous function to prevent polluting the global area. - Added the "use strict" directive and cleaned up errors that produced with undeclared variables. - Added --spell_slots tag to display a formatted list of available spell slots. - Updated --spell_list to hide the entire row if the list is empty. --- Overview
PowerCards allows
you to define highly customizable templated output for PC and NPC actions,
spells, abilities, statistics, or almost any other purpose you can come up
with. Their original purpose was to present ability and attack information
(powers) in a format similar to the power blocks from the official D&D 4E
products, but the format works well for any system. PowerCards are output to
the chat window with full HTML/CSS formatting. A handful of options use
information from the 5E OGL sheet, but these options are not critical to the
functioning of the core features of the script.
Here is an example PowerCard
with an NPC attacking one of my player characters:
Here we can see that the Grave Hound is attacking our druid Kara with a multiattack that consists of two Necrotic Bite attacks. Both are hits agains Kara's AC of 13. In total, Kara will be taking 7 points of piercing damage and 11 points of Necrotic damage from this attack. Behind the scenes, this card also played a growling sound effect when the hound attacked and showed a splatter of blood on Kara's token since the attack hit.
Using the Script
A PowerCard is the
result of a chat string beginning with the “!power” API command, followed by a
list of lines or configuration options you want to display on the card, with
the whole thing enclosed in double curly brackets ({{ and }}). These lines and
options are identified by tags, which always start with two dashes (--)
followed by the tag name. This is followed by a vertical bar (|) and then the
content of the tag.
The output of the PowerCard is divided into two sections: an
optional emote section that identifies the actors, describes the action, etc.,
and the card itself, which consists of a title block and alternately colored
line sections that correspond to the tags on the card.
Lets begin by looking at a very simple card:
!power {{
--name|Melee
Attack
--Attack:|[[ 1d20
]] vs AC
}}
The output for this
card will look something like this:
Any line that
doesn’t contain a reserved tag name will be displayed as bold text followed by
the tag contents. In this case, a 1d20 is being rolled (die rolls are specified
by enclosing them in double square brackets) , followed by the rest of the text
in the content of the tag.
Multiple tags can be
used, and will create new rows for each tag:
!power {{
--name|Melee
Attack
--Attack:|[[
1d20 ]] vs AC
--Damage:|Target takes [[ 1d8 + 2 ]] damage
on a hit.
}}
Now we will get
output like this:
Character Sheet
Information Tags These tags are described in the Wiki. Here are a couple of screenshots using them: !power {{
--name|@{selected|character_name}
--whisper|GM
--format|badguys
--emote|
--tokenid|@{selected|token_id}
--npc_attribute_summary|@{selected|character_id}
--npc_qualities_summary|@{selected|character_id}
--npc_skills_summary|@{selected|character_id}
--!Actions|**Available
Actions**
--npc_action_list|@{selected|character_id}
--!Reactions|**Available
Reactions**
--npc_reaction_list|@{selected|character_id}
--!LA|**Legendary
Actions**
--npc_legendaryaction_list|@{selected|character_id}
--!TR|**@{selected|character_name}
Traits**
--npc_trait_list|@{selected|character_id}
}}
Here is an example that combines both the --spell_slots and the --spell_list tags: !power {{ --format|bigbad --orowbg|#CEC7B6 --erowbg|#CEC7B6 --name|Spell List --tokenid|@{selected|token_id} --emote|@{selected|character_name} --leftsub|Atk Bonus: @{selected|spell_attack_bonus} --rightsub|Save DC: @{selected|spell_save_dc} --spell_slots|@{selected|character_id} --spell_list|@{selected|character_id} }}