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

1427640866
The Aaron
Pro
API Scripter
Dev and Prod are in parity now, you can use the same script on both.
1427640985
The Aaron
Pro
API Scripter
Kevin said: I had this problem happen again this morning on a new campaign that I am setting up. I don't know what I did again to cause this issue, however I am starting to suspect that if you clear the chat archive it may resolve the issue. That sounds reasonable. The issue that Riley fixed in my campaign had to do with a timing issue with one of the player's messages. Removing those messages fixed the issue. He removed all that player's messages manually, but removing all messages seems like it would fix the problem as well. I know Riley is looking into this problem, so hopefully a patch will show up soon.
1427646236

Edited 1427646804
The Aaron
Pro
API Scripter
Iskoaya said: = HoneyBadger said: I think he meant handout ID/URL, so they can link to them in their macros. this! other than making a handout index and listing every handout in [Handout Name] i dont know how to grab the ID/URL Ah. Well, you could go down to line 371 and insert this (you want it right before " str = formatter(str); " in the function doInlineFormatting() ): str = _.reduce( content.match(/@[JHC]@.*?@[JHC]@/g), function(m, s, i) { var parts = s.replace(/@([JHC])@(.*)@[JHC]@/, '$1:$2').split(/:/), types = ('J' === parts[0] ? ['character','handout'] : ( 'H' === parts[0] ? ['handout'] : ['character']) ), matchName = parts[1].replace(/\s+/g,'').toLowerCase(); urls.push(_.chain(filterObjs(function(o){ return _.contains(types, o.get('type')) && (o.get('name').replace(/\s+/g,'').toLowerCase() === matchName); })) .map(function(o){ var n = o.get('name'), t = o.get('type'); return '&lt;a class="showtip tipsy" title="'+t+': '+n+'" href="<a href="http://journal.roll20.net/'+t+'/'+o.id+'&quot;&gt;'+n+'&lt;/a" rel="nofollow">http://journal.roll20.net/'+t+'/'+o.id+'"&gt;'+n+'&lt;/a</a>&gt;'; }) .value() .join(' ') || ' Error: Not found: "'+parts[1]+'" ' ); return m.replace(s, '@@' + (urls.length-1) + '@@'); }, str ); That adds the following formats: @J@...@J@ -- whatever is between is treated as the name of either a character or handout @C@...@C@ -- whatever is between is treated as the name of a character @H@...@H@ -- whatever is between is treated as the name of a handout This will provide links to all the characters and handouts named Rook: !power --name|Test Journal Links --test|@J@Rook@J@ (I added a handout named Rook for testing...) This will only provide links to characters named Rook: !power --name|Test Journal Links --test|@C@Rook@C@ Case and spaces are all ignored inside the tags, so all of these are the same: @J@Rook@J@ @J@rOoK@J@ @J@ R oo k @J@ Add of course, it will give feedback if it can't find anything: Cheers! Edit : Adjusted the code to add a tooltip showing what's linked to:
1427650161
Gen Kitty
Forum Champion
Aaron: In ancient times, we would be chanting, "Burn the witch!" ^_-
Or.... worshipping him as a god walking amongst men.
1427652255
The Aaron
Pro
API Scripter
<a href="https://www.youtube.com/watch?v=3dO0MPsULWY" rel="nofollow">https://www.youtube.com/watch?v=3dO0MPsULWY</a> =D
GenKitty said: Aaron: In ancient times, we would be chanting, "Burn the witch!" ^_- BS we would! Sean G. said: Or.... worshipping him as a god walking amongst men. ah, a fellow convert, hail to thee bruddah! The Aaron said: Ah. Well, you could go down to line 371 and insert this (you want it right before " str = formatter(str); " in the function doInlineFormatting() ): I see the following: close to 370 but not quite, i believe you have extra stuff in yours that i dont in mine: ); str=formatter(str); return _.reduce( urls, function(m,s,i) { return m.replace('@@'+i+'@@',s); }, str ); } i should insert like this? ); YOUR CODE HERE str=formatter(str); return _.reduce( urls, function(m,s,i) { return m.replace('@@'+i+'@@',s); }, str ); } Yes? no? maybe so? i dont know html so im clue less lol sorry for this headache
1427662173
The Aaron
Pro
API Scripter
Yup, just like that. :)
1427663141
Gen Kitty
Forum Champion
I have an odd question. Without adding any more code to the script , is it possible to preload a multi-target with IDs? For example, I might have a card that does this: !power {{ --name|**Party Perception** --format|skill --whisper|GM --!L1|P [[10+@{Ekima|Perception}]] | A [[1d20+@{Ekima|Perception}]] Ekima --!L2|P [[10+@{Kai|Perception}]] | A [[1d20+@{Kai|Perception}]] Kai --!L3|P [[10+@{Legius|Perception}]] | A [[1d20+@{Legius|Perception}]] Legius --!L4|P [[10+@{Rizzak|Perception}]] | A [[1d20+@{Rizzak|Perception}]] Rizzak --!L5|P [[10+@{Sha-Korat|Perception}]] | A [[1d20+@{Sha-Korat|Perception}]] SK }} and I might want to turn it into this: !power {{ --name|**Party Perception** --format|skill --whisper|GM --target_list|@{target|1st|token_id} | @{target|2nd|token_id} | @{target|3rd|token_id} | @{target|4th|token_id} | @{target|5th|token_id} --Result#?{Number of targets|6}|P: [[10+%%Perception%%]] | A: [[1d20+%%Perception%%]]%%token_name%% }} But instead of having to click the party each time, it would be nice to preload the target list with the IDs of the characters.
1427669564

Edited 1427670461
The Aaron
Pro
API Scripter
You can do that, sort of. @{target} gets replaced BEFORE it is sent to the API server, so by the time the powercard script sees it, the @{target}'s will look like -Jiys1q1PMH_I90BUbhE . So, you could just chat or whisper some @{target} calls to yourself and put that string in instead of them. The "sort of" part comes in with the fact that the Token IDs are specific to the page they are on. Probably for this to be satisfactory, you'd need the add the ability to pass character_ids to the --target_list which would require adding some code (probably not too much code though!). token_name and the bar charms wouldn't work in that case, but for your use it would probably be fine. ... If you wanted to do that, you just replace the function doTargetInfo() around line 412 with this version (which I added support for skips to, as it was ignoring SUPPRESS_INLINE_CHARMS): function doTargetInfo(content, TargetList, skip) { // PARSE FOR TARGET INFO REPLACEMENT CHARMS if(skip) return content; var Token = getObj("graphic", TargetList[0]), Character; if (Token === undefined) { Token = {get: function(){return 'ERROR';}}; Character = getObj("character", TargetList[0]); } else { Character = getObj("character", Token.get("represents")); } // TOKEN CHARMS return content.replace(/%%(.*?)%%/g, function (m, charm) { var attr; switch (charm) { case 'token_name': return Token.get('name'); case 'bar1': case 'bar2': case 'bar3': return Token.get(charm+'_value'); case 'bar1_max': case 'bar2_max': case 'bar3_max': return Token.get(charm); default: return (Character && (attr=getAttrByName(Character.id, charm)) && '[['+attr+']]') || 'ERROR'; } }); } That would let you do something like this: !power --target_list|-Jh1tMI3qnsFKEV66BuA --name|Character Charms --Warlock Level|%%warlock_level%% and get this output: And report errors if you tried to get something from the non-existent token:
1427669784

Edited 1427669896
Yeah, you can. Just replace @{target|1st|token_id}, the whole thing, with the token id. Totally forgot about tokens have different id's per page...
I am somewhat confused, GenKitty... why would you want to switch to token_ids instead of just using the @{character_name|attribute} method already built in to Roll20?
1427671055
Gen Kitty
Forum Champion
I want to switch to a more elegant layout for some of my macros, but I don't want to have to click on my players each time I run the macro. It's not the @{character|attribute} I'm trying to get away from in this particular macro example, but the need to click on targets. It's not a big enough deal to add code to the script, I was just wondering if the capacity existed already :&gt;
you cant use @{character's name|token_id} in target list?
1427677257
The Aaron
Pro
API Scripter
Iskoaya said: you cant use @{character's name|token_id} in target list? No, it wouldn't know which token to give you the id for. Likely your pc's tokens would be on every page, each with a different token id.
1427681679

Edited 1427683038
ok aaron i changed my script, so now the function looks like this: function doInlineFormatting(content, ALLOW_URLS, ALLOW_HIDDEN_URLS) { // PARSE FOR INLINE FORMATTING var urls=[], str, formatter=function(s) {r return s .replace(/__(.*?)__/g,"&lt;u&gt;$1&lt;/u&gt;") .replace(/\*\*(.*?)\*\*/g,"&lt;b&gt;$1&lt;/b&gt;") .replace(/\/\/(.*?)\/\//g,"&lt;i&gt;$1&lt;/i&gt;") .replace(/\^\^/g,"&lt;br&gt;") .replace(/\^\*/g,"&lt;span style='margin-left: 1em;'&gt;&lt;/span&gt;") .replace(/\$\$(#([a-fA-F0-9]{3}|[a-fA-F0-9]{6}))\|(.*?)\$\$/g,"&lt;span style='color: $1;'&gt;$3&lt;/span&gt;") .replace(/\]\_\[/g,"&lt;hr style='border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3); margin-bottom: 2px; margin-top: 2px;'/&gt;") .replace(/\~\L(.*?)\~\L/g,"&lt;div style='text-align: left;'&gt;$1&lt;/div&gt;") .replace(/\~\C(.*?)\~\C/g,"&lt;div style='text-align: center;'&gt;$1&lt;/div&gt;") .replace(/\~\R(.*?)\~\R/g,"&lt;div style='float: right;'&gt;$1&lt;/div&gt;&lt;div style='clear: both;'&gt;&lt;/div&gt;") ; }; str = _.reduce( content.match(/@@.*?@@/g), function (m,s,i) { var parts=s.replace(/@@(.*)@@/,'$1').split(/\|\|/), url = parts.shift().replace(/^\s*(http(s)?:\/\/|\/\/()|())/, 'http$2://'), text = formatter(parts.join('||')); if(ALLOW_URLS) { if(ALLOW_HIDDEN_URLS) { urls[i]='&lt;a href="'+url+'"&gt;'+(text||url)+'&lt;/a&gt;'; } else { urls[i]='&lt;a href="'+url+'"&gt;'+text+' ['+url+']&lt;/a&gt;'; } } else { urls[i]=s; } return m.replace(s,'@@'+i+'@@'); }, content ); str = _.reduce( content.match(/@[JHC]@.*?@[JHC]@/g), function(m, s, i) { var parts = s.replace(/@([JHC])@(.*)@[JHC]@/, '$1:$2').split(/:/), types = ('J' === parts[0] ? ['character','handout'] : ( 'H' === parts[0] ? ['handout'] : ['character']) ), matchName = parts[1].replace(/\s+/g,'').toLowerCase(); urls.push(_.chain(filterObjs(function(o){ return _.contains(types, o.get('type')) && (o.get('name').replace(/\s+/g,'').toLowerCase() === matchName); })) .map(function(o){ var n = o.get('name'), t = o.get('type'); return '&lt;a title="'+t+': '+n+'" href=" <a href="http://journal.roll20.net/'+t+'/'+o.id+'&quot;&gt;'+n+'&lt;/a" rel="nofollow">http://journal.roll20.net/'+t+'/'+o.id+'"&gt;'+n+'&lt;/a</a>&gt; '; }) .value() .join(' ') || ' Error: Not found: "'+parts[1]+'" ' ); return m.replace(s, '@@' + (urls.length-1) + '@@'); }, str ); str=formatter(str); return _.reduce( urls, function(m,s,i) { return m.replace('@@'+i+'@@',s); }, str ); }
1427683114
The Aaron
Pro
API Scripter
That is the right spot. Let me know if that works for you!
1427725737
vÍnce
Pro
Sheet Author
Anything that can be done on the powercard side of the equation to help this? (3d dice) Source post Riley D. said: Oh, okay, I remember what's going on here. So with the new changes to the 3D Dice, we wait until we actually "render" the message to your window to show the 3D Dice rolling. With an API command, the original message with the roll is never actually rendered. The PowerCards script does use that data to later display dice results, but that's a new message (one created with sendChat()) and it's not a "real" roll, it's just HTML that looks like a roll was made. So we have message A, which is "!power --name|Test --Roll|[[1d20]]". That message is calculated client-side (the rolls are made, etc.), but it's never shown since it's an API command. The calculated message (including dice results) are then sent to the API server. PowerCards script then makes a new message, message B, which contains HTML that looks like an inline roll but is really not an "actual" roll, and then puts the results from the roll from message A in there. Since message A is never shown to anyone, and since message B doesn't actually have any rolls in it, you don't get the 3D Dice shown on your screen. I can probably make it so that the 3D Dice can show to the person who is making the original roll via the API command, but I won't be able to have it show to everyone. Because when do the original roll, in message A, we don't know on our end who should be able to see it (the API script determines that later). Which is the bug we fixed (where 3D Dice were showing to everyone when they shouldn't have been). So with the current way it works, our options are either: 1) Make it so 3D Dice show to everyone regardless of who should actually see the final result, or 2) Only show 3D Dice to people who should see the final result, but not be able to show them for API scripts since those have their own way of determining who the message goes to (an !api command may end up as a whisper, a regular message, etc.) I'll give it some more thought and see if there's a way to better support it. But at least now hopefully you know what's going on :-).
Nope. PowerCards have never played well with 3D dice.
It's sad because they were working well together until they made this latest change that hid inline rolls until the dice completed their rolls.
1427728285
The Aaron
Pro
API Scripter
As HB alluded to in the other thread, an API function (or better, option to sendChat() ) that allowed telling the system who should see which rolls would let this happen, but it's not something that can currently be triggered by the API side.
Which is understandable. It's good to know the issue is not caused by PowerCards (or the API in general), rather the changes that were made to the server instead. Still, sad panda. More sad when we don't get to see an explosion of dice appear on a rogue's Sneak Attack. That's almost the most intimidating aspect. Who cares if you miss every swing, or roll 1s... that explosion of dice everywhere when kicking out a PowerCard -- that's where it's at!
1427791017
Ziechael
Forum Champion
Sheet Author
API Scripter
I may be missing something, but for some reason my powercards aren't sending an output to chat anymore (i wondered if it might be to do with the api-chat thread that Riley has reported as fixed but clearing the chat cache hasn't helped). I don't get an error message and have made sure i've got the latest version of the script... i'm genuinely at a loss as i've never had problems previously :( Not sure what steps to take to help identify my issue, are there any known scripts that block powercards, i've only added Aaron's ammo script since it last worked (have tried disabling all other scripts too).
Thanks for your help guys. I have turned off the 3D dice, cleared the chat log and disabled and renabled the script and now its working again. Awesome! Rob
1427795340

Edited 1427797991
Ziechael
Forum Champion
Sheet Author
API Scripter
Rob said: Thanks for your help guys. I have turned off the 3D dice, cleared the chat log and disabled and renabled the script and now its working again. Awesome! Rob I knew i'd read it somewhere! I have the same problem as reported by Rob but no joy following the same steps :( To be fair the only difference to what i'd already tried was the 3d dice which we don't have enabled anyway... *puts patient hat back on* :) [edit]: *takes patient hat off and puts 'read things carefully hat on* Have retried, this time clearing the chat log in campaign details rather than in the campaign itself (after extracting the whole thing to a textedit note page ofcourse) and now everything is working again as expected. Thanks for your response Rob, solving your problem helped me with mine :)
1427804319
The Aaron
Pro
API Scripter
Was that a Dev or Prod campaign Z?
Aaron, I had an issue with this in a Dev campaign, @Kevin posted a sendchat error to Riley in another thread. The 3D dice don't work but I was eventually able to get the !power chat output to work after I cleared chat archive.
I'm sorry if I am being dense, but my co-GM asked me if necessary to be able to increase the font size on the power card. I said sure, there's a setting for that: (for instance, " titlefontsize - Sets the size of the name of the powercard") but I suddenly realized I had no idea what values this setting takes. Should i use --titlefontsize|12 or --titlefontsize|large or --titlefontsize|2px? I hope this isn't inappropriate for the thread; thought maybe in the future there might eventually be someone else who is also at the perfect crossroads of ignorant and needful who might benefit from this information, or else I'd have just sent a pm.
1427812627
The Aaron
Pro
API Scripter
Looks like you want to use whatever you might similarly use for CSS, so: --titlefontsize|14px --titlefontsize|2em --titlefontsize|.5in etc. See: <a href="http://www.w3schools.com/cssref/css_units.asp" rel="nofollow">http://www.w3schools.com/cssref/css_units.asp</a> for details on sizes.
1427816088
Ziechael
Forum Champion
Sheet Author
API Scripter
The Aaron said: Was that a Dev or Prod campaign Z? For reference it is on Prod :)
Just want to share that the march 28th formatting update is amazing and my players love you for it.
Aaron deserves that credit there. Such a simple implementation that makes a huge difference.
Occasionally my api errors out with "unexpected token s" causing us to reset it. It's not a big deal and it only happens every so often (maybe once every other day, usually not during gametime) so it isn't a critical issue at all. That said, we're only running powercards in our API and I'm wondering where/how this might be setting off. Usually it happens when the game isn't running (when we reopen it after a few hours or a day of not playing we find powercards stopped and that error).
Encartrus said: Occasionally my api errors out with "unexpected token s" causing us to reset it. It's not a big deal and it only happens every so often (maybe once every other day, usually not during gametime) so it isn't a critical issue at all. That said, we're only running powercards in our API and I'm wondering where/how this might be setting off. Usually it happens when the game isn't running (when we reopen it after a few hours or a day of not playing we find powercards stopped and that error). API bug not native to this script. press the save button and it should fix itself.
Yep! That's what we do and it works out fine. Wasn't sure if you guys knew of a more permanent solution.
New thread: <a href="https://app.roll20.net/forum/post/1793309/script-powercards-2-thread-2" rel="nofollow">https://app.roll20.net/forum/post/1793309/script-powercards-2-thread-2</a>