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

[Script] Power Cards

Thanks for the advice, now the cards are presenting correctly. However, when the macro is run, the script is apparently ran twice, resulting in two power cards being displayed in the chat window for one macro button press. Any idea why it would be doing that now?
You may have an old copy of the script in there in a blank tab... I dunno. It's a common problem with api stuff.
1409112263
The Aaron
Roll20 Production Team
API Scripter
@Cody - screen shots of an invisible tab on this topic: <a href="https://app.roll20.net/forum/post/1120857/api-scripts-do-not-get-deleted#post-1123938" rel="nofollow">https://app.roll20.net/forum/post/1120857/api-scripts-do-not-get-deleted#post-1123938</a>
Tinkering with a slightly modified look for power cards. This would utilize /desc and /direct to create the custom emote as shown below. I also figured out how to stretch the power card all the way to the left. It only works if you're NOT using chat avatars though. The drawback to trying to include the avatar of the character, is that there is no easy way to get the avatar. When you click a macro, it's sent to the chat window and then sent onwards... meaning no identifying information other than who you're SpeakingAs is sent. The only way I can get the character avatar would be to add a --charid| {...} tag that would have to go in every macro and players would need some way to get the characterid. Thoughts?
HoneyBadger said: The only way I can get the character avatar would be to add a --charid| {...} tag that would have to go in every macro and players would need some way to get the characterid. Thoughts? I like the new look. Wouldn't @{selected|character_id} work for players?
Yeah, but not everyone uses their macros as token actions... so some macro's would be used without a token selected.
If the character id is static for a campaign then using that once in chat will generate the number id for your players to substitute in to their macro
That also requires the GM to have linked the token to the character sheet.
<a href="https://app.roll20.net/forum/post/1034829/script-a" rel="nofollow">https://app.roll20.net/forum/post/1034829/script-a</a>... aaron's ammo script is able to list character id's linked to a token. Possibly you could modify that code to search for character id's linked to a character name
1409150216
The Aaron
Roll20 Production Team
API Scripter
I added that !get-represents as a convenient way to get the character ID so that users could supply it and not need to have a token selected (or pass a token id). You are certainly welcome to the code! =D HoneyBadger is right though, there isn't another good way to get the character id in the API (but it would be great if there was!).
1409152646
The Aaron
Roll20 Production Team
API Scripter
The Edge of the Empire Dice script goes through and instruments all the characters with attributes containing the character id, then uses @{characterid} in the macros it creates. Certainly that instrumentation would be easy enough to write and could be included/checked as an on('ready',...) action. Then users of the script could just specify it that way. You could even check all macros with a line beginning with !power have --charid|@{characterid} in them, and add it if it's missing. =D
Aaron said: The Edge of the Empire Dice script goes through and instruments all the characters with attributes containing the character id, then uses @{characterid} in the macros it creates. Certainly that instrumentation would be easy enough to write and could be included/checked as an on('ready',...) action. Then users of the script could just specify it that way. You could even check all macros with a line beginning with !power have --charid|@{characterid} in them, and add it if it's missing. =D That might be a possibility, but I want to keep the script small.
1409178264
The Aaron
Roll20 Production Team
API Scripter
Which part? Adding CharacterID as an attribute is only a few lines. Checking and adding --charid|@{characterid} is a bit bigger, but manageable. Maybe a companion script that does that. I could even write it and provide it... /em makes a note on his list of scripts to write...
Looping through characters to find the right macro would not be efficient. I'll figure something out.
1409195305

Edited 1409199439
I am trying to include functionality from one of the examples on the character sheet. The example is: [[(floor(@{level}/21)*(@{power-1-weapon-num-dice}d@{power-1-weapon-dice}))+@{power-1-weapon-num-dice}d@{power-1-weapon-dice}+@{power-1-damage}]] Basically I am after adding a die of damage to the power once the character level reaches 21. In my case it is an implement power so it is more simple than the example above and adding 1d6 at level 21 (or so I'd hope). My attempted roll for the --Hit line of a power card is: [[(floor(@{level}/21)*(1d6)) +1d6 +@{power-3-damage} +@{DmgBns_Psychic}]] I use @{DmgBns_Psychic} in a handful of my powers, so that should not be an issue. Can someone explain to me what I have wrong? The log I got from the GM is: undefined:1 (Math.floor(8/21)* SyntaxError: Unexpected end of input at Object.PowerCardScript.parseRollData (evalmachine.&lt;anonymous&gt;:323:61) at Object.PowerCardScript.buildInline (evalmachine.&lt;anonymous&gt;:252:43) at evalmachine.&lt;anonymous&gt;:200:40 at checkFinishedOps (
You are dividing by 21... It should be 2. Might be an issue.
1409199176

Edited 1409199369
HoneyBadger said: You are dividing by 21... It should be 2. Might be an issue. But if 1d6 is added at level 21, should it not be floor(level/21)? Thus when level is less than 21 it will be 0*1d6. If level &gt;= 21 it will be 1*1d6. It is not a half level calculation. I've updated my initial post to make the desired calculation clear.
1409226151

Edited 1409226170
I dunno then... does it work outside of a power card macro?
1409237122
The Aaron
Roll20 Production Team
API Scripter
HoneyBadger said: Looping through characters to find the right macro would not be efficient. I'll figure something out. I'm talking about doing it once on('ready',...) and checking one specific one on('change:ability:action',...). I wouldn't suggest iterating across all abilities on('chat:message').
1409355160
The Aaron
Roll20 Production Team
API Scripter
Aaron said: The Edge of the Empire Dice script goes through and instruments all the characters with attributes containing the character id, then uses @{characterid} in the macros it creates. Certainly that instrumentation would be easy enough to write and could be included/checked as an on('ready',...) action. Then users of the script could just specify it that way. You could even check all macros with a line beginning with !power have --charid|@{characterid} in them, and add it if it's missing. =D I don't know how I missed this before, but it looks like this always works: @{selected|character_id} @{character_id} &lt;-- in a token macro works fine @{target|character_id}
Cool. Will have to look into that later then.
HoneyBadger said: I dunno then... does it work outside of a power card macro? Yes. I can use [[(floor(@{selected|level}/21)*(1d6)) +1d6 +@{selected|power-3-damage} +@{selected|DmgBns_Psychic}]] pasted into chat and as an ability macro and it works just fine. Also just adding "/w &lt;name&gt; " at the beginning of the power to keep it from posting as a power card allows it to work. But if it attempts to process that code inside of a power card and show it as one it fails.
Spazz451 said: HoneyBadger said: I dunno then... does it work outside of a power card macro? Yes. I can use [[(floor(@{selected|level}/21)*(1d6)) +1d6 +@{selected|power-3-damage} +@{selected|DmgBns_Psychic}]] pasted into chat and as an ability macro and it works just fine. Also just adding "/w &lt;name&gt; " at the beginning of the power to keep it from posting as a power card allows it to work. But if it attempts to process that code inside of a power card and show it as one it fails. It seems to work correctly for me. Make sure there isn't any typos, also make sure you have the latest version of the script. Here is the result I got. [[(floor(@{level}/21)*(@{power-1-weapon-num-dice}d@{power-1-weapon-dice}))+@{power-1-weapon-num-dice}d@{power-1-weapon-dice}+@{power-1-damage}]]
Question for you HB. How possible would it be to make hyperlinks clickable within a powercard? Even better would be if we could create a link with a title. For example "This spell fills a single subject with a feeling of horrible dread that causes it to become shaken "
That would be awesome! Wouldn't have to constantly google an item or an effect. :)
Yeah, it is doable. Working on slimming down the script at the moment and making it easier to customize the cards at the moment.
Got the new style of emote done. Uses the --emote tag, so there won't be a need to change your macros too much... you will just add --charid|@{character_id} to the macro and the GM needs to set POWERCARD_CUSTOM_EMOTE to true in the script. Still cleaning up the code here and there, trying to reduce the complexity without breaking anything... and it is slow going. Will post an update when I put the new version in the original post.
I think having the ability to specify a "tittle" attribute for some text would be useful so you could just mouseover a specific word like shaken and get that helpful popup appear to explain the status effect without having to go across to some other side.
Adding title to a span would be far easier than parsing html links... and probably safer.
1409566688

Edited 1409566763
Sorry HB got bored with my work I am meant to be doing and inspired by this idea, so wrote the code to do it :) Goes directly under the code block for the italics. Uses the following format: Something here _(*_This is what is shown_*_This is what appears on the link_*)_ and then you continue on Will display the "This is what is shown" in italic and if you hover over it you get the "this is what appears on the link" popping up. ---------- // Abbreviations _(*_Abbreviation here_*_Explanation of abbreviation here_*)_ if ((Content.indexOf("_(*_") != -1)&&(Content.indexOf("_*_") != -1) &&(Content.indexOf("_*)_") != -1)) { // Do stuff... while ((Content.indexOf("_(*_") != -1)&&(Content.indexOf("_*_") != -1) &&(Content.indexOf("_*)_") != -1)) { var iOpen = Content.indexOf("_(*_"); var iStar = Content.indexOf("_*_"); var iClose = Content.indexOf("_*)_"); var strStart = Content.substring(0, iOpen); var strTitle = Content.substring(iStar + 3, iClose); var strText = Content.substring(iOpen + 4, iStar); var strRest = Content.substring(iClose + 4, Content.length); Content = strStart + "&lt;i title='" + strTitle + "'&gt;" + strText + "&lt;/i&gt;"+ strRest; } } ----------
Looks good... though not quite how I would do it. Not everyone will want the hover-over text to be italic. I will look into adding something like this tomorrow. For now... I am updating the main post with the new emotes.
Updates September 1st, 2014 ~ 6:30 am eastern: Added a custom emote option that is triggered by adding --charid|@{character_id} to your emote. This will grab the avatar from your character sheet and prefix the contents of the --emote| tag with that image and format it without the colored background and italicize the text. See examples further down in this thread. If you want to use the new emote without an image, add a single ! exclamation mark at the start of the content of the emote tag to prevent the image from showing. Example: --emote|Leaps into the fray. shows the avatar of the character... --emote|!Leaps into the fray. does not show the avatar... Removed --lb| from list of tags. Do not use. Removed --desc| from list of tags. Do not use.
Indents now seem to break the formatting as per the below screenshot. The indent was on the Notes section. Also the avatars work for me in firefox but not chrome for some reason.
Hrm... weird. Will have to check that.
Avatars now work in Chrome. Don't have enough time before work to look into the indents, but I may be able to look at it during lunch tonight.
Thanks HB, you sir are a legend!
I feel really stupid for not catching this one more quickly. I had forgotten that creating an indent is a whole new RowStyle variable... and had not put the margin changes into that one. Updates September 2nd, 2014 ~ 1:40 am eastern: Minor bugfix... indents no longer break the left hand side of the power card. If you want to fix this yourself without replacing the whole script, go to lines 219 and 221 and add the following in front of padding: 5px margin: 0px 0px 0px -10px;
Awesome, working perfectly now. I like that I can use this to add emotes to NPC attack rolls in my pathfinder sheet without giving away the name of the enemy that is attacking the players. :)
Zepth said: Awesome, working perfectly now. I like that I can use this to add emotes to NPC attack rolls in my pathfinder sheet without giving away the name of the enemy that is attacking the players. :) +1
1409992788

Edited 1409992874
Feature request: Could it be possible to have multiple, color-selectable options for high/low-lighting an individual roll? Using an attack roll with a rapier in Pathfinder as an example, having something like [LR|(red) 1] for crit fails, [HRa|(green) 18] for crit threats, and [HRb|(blue) 20] for automatic hits? Of course, you might want to use HR1/HR2/etc instead of HRa/HRb/etc, and I'd imagine that (red) (green) (blue) would prolly just be #A02 style hex codes like the color options elsewhere... I just wanted to make it understood without having to look up some hex color real quick. Another feature that might be of value (though I don't know any systems that use it) would be to have a highlight for a range of values, like a [[ [NR|(color) 7-9] 2d6]] to highlight 7s through 9s on a 2d6 roll.
I'll put it on the list of things to consider. This is my long weekend to work. So I don't get much done at all during these three days.
1410637056
Gen Kitty
Forum Champion
Bug Report I was testing LR/HR and encountered this: !power --name|Test Action --leftsub|At-Will --rightsub|Standard Action --attack|[[[LR3][HR4]1d6]] Testroll By my understanding, this is a bug.
Combo low/high does not work yet.
1410772940

Edited 1410773223
I broke your script with indentations, is there something that I did wrong? !power --format|dnd4e --name|@{power-3-name} --title|@{class} Attack @{power-3-level} --usage|@{power-3-usage} --action|@{power-3-action} --emote|Block's attack surrounds a foe with a shroud of crackling lightning, threatening retribution for strikes against his allies. --charid|@{character_id} --Keywords| Augmentable, Lightning, Psionic, Weapon --Range|@{power-3-range} --Target(s)|One creature --attack|[[1d20+@{power-3-attack}]] --defense|@{power-3-def} --damage|[[(1*@{power-3-weapon-num-dice})d@{power-3-weapon-dice}+@{power-3-damage}]] lightning damage. Until the start of your next turn, the target takes [[@{constitution-mod}]] lightning damage whenever it hits one of your allies. --text1|**Augment 1** --^1Hit|As above, and, until the start of your next turn, the target also takes the lightning damage whenever it shifts to a square adjacent to one of your allies. This is what it shows: Also, I had problems getting the text only line to even show, until I did --text1|**Augment 1** At first I tried --text|**Augment 1** which didn't work. If I sound ungrateful, I'm not. Thanks for the script!
1410773500

Edited 1410773574
I broke your script with indentations, is there something that I did wrong? !power --format|dnd4e --name|@{power-3-name} --title|@{class} Attack @{power-3-level} --usage|@{power-3-usage} --action|@{power-3-action} --emote|Block's attack surrounds a foe with a shroud of crackling lightning, threatening retribution for strikes against his allies. --charid|@{character_id} --Keywords| Augmentable, Lightning, Psionic, Weapon --Range|@{power-3-range} --Target(s)|One creature --attack|[[1d20+@{power-3-attack}]] --defense|@{power-3-def} --damage|[[(1*@{power-3-weapon-num-dice})d@{power-3-weapon-dice}+@{power-3-damage}]] lightning damage. Until the start of your next turn, the target takes [[@{constitution-mod}]] lightning damage whenever it hits one of your allies. --text1|**Augment 1** --^1Hit|As above, and, until the start of your next turn, the target also takes the lightning damage whenever it shifts to a square adjacent to one of your allies. This is what it shows: Also, I had problems getting the text only line to even show, until I did --text1|**Augment 1** At first I tried --text|**Augment 1** which didn't work. Edit: I finished the macro, and it still doesn't work. I figured I'd give you the finished macro: !power --format|dnd4e --name|@{power-3-name} --title|@{class} Attack @{power-3-level} --usage|@{power-3-usage} --action|@{power-3-action} --emote|Block's attack surrounds a foe with a shroud of crackling lightning, threatening retribution for strikes against his allies. --charid|@{character_id} --Keywords| Augmentable, Lightning, Psionic, Weapon --Range|@{power-3-range} --Target(s)|One creature --attack|[[1d20+@{power-3-attack}]] --defense|@{power-3-def} --damage|[[(1*@{power-3-weapon-num-dice})d@{power-3-weapon-dice}+@{power-3-damage}]] lightning damage. Until the start of your next turn, the target takes [[@{constitution-mod}]] lightning damage whenever it hits one of your allies. --text1|**Augment 1** --^1Hit|As above, and, until the start of your next turn, the target also takes the lightning damage whenever it shifts to a square adjacent to one of your allies. --^0text2|**Augment 2** --^Hit|An additional [[(1*@{power-3-weapon-num-dice})d@{power-3-weapon-dice}+@{power-3-damage}]] lightning damage. Until the start of your next turn, the target takes [[@{constitution-mod}]] lightning damage whenever it hits one of your allies. Here's what it looks like: Finally...is it my imagination, or has the space between the top of the power card and the name of the power gotten smaller?
1410781043

Edited 1410781169
I fixed that indent problem over a week ago. Your version is slightly out of date. And yes, I've been messing around with formatting of the title and such. edit - What the fuck... the changes I put in to fix indenting aren't in there now. &gt;_&lt; Adding them back in now.
1410793531

Edited 1410793779
Thank you very much HoneyBadger, it looks beautiful now! Just one thing I want to make you aware of, it's not a major issue but if it's an easy fix then my OCD would appreciate it. !power --format|dnd4e --name|@{power-3-name} --title|@{class} Attack @{power-3-level} --usage|@{power-3-usage} --action|@{power-3-action} --emote|Block's attack surrounds a foe with a shroud of crackling lightning, threatening retribution for strikes against his allies. --charid|@{character_id} --Keywords| Augmentable, Lightning, Psionic, Weapon --Range|@{power-3-range} --Target(s)|One creature --attack|[[1d20+@{power-3-attack}]] --defense|@{power-3-def} --damage|[[(1*@{power-3-weapon-num-dice})d@{power-3-weapon-dice}+@{power-3-damage}]] lightning damage. Until the start of your next turn, the target takes [[@{constitution-mod}]] lightning damage whenever it hits one of your allies. --text1|**Augment 1** --^1Hit| As above, and, until the start of your next turn, the target also takes the lightning damage whenever it shifts to a square adjacent to one of your allies. --^0text2| **Augment 2** --^Hit|An additional [[(1*@{power-3-weapon-num-dice})d@{power-3-weapon-dice}]] lightning damage. Until the start of your next turn, the target takes [[@{constitution-mod}]] lightning damage whenever it hits one of your allies. After indenting with --^1Hit|, and then using --^0text2 to remove the indent, Augment 2 is actually moved all the way to the left, without any padding on the left. Would this be an easy fix, if it's not, don't trouble yourself over it, but if it is, I would greatly appreciate it. Thanks HoneyBadger!
1410795558
The Aaron
Roll20 Production Team
API Scripter
Testing with this case: !power --foo0|bar --foo1|bar --^1foo2|bar --^0foo3|bar --^1foo4|bar I added this log message for testing: log('Indent: ['+Indent+']'+' type: '+(typeof Indent)); Which results in this: "Indent: [1] type: string" "Indent: [0] type: string" "Indent: [1] type: string" This will fail because '0' is a string and isn't equal to 0 (a number) if (Indent === 0) { Changing it to this fixes the issue (Line 218): if (Indent === '0') {
That did it, thanks a ton Aaron.