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 HELP] Blind Whisper Script

I am looking to update my blind whisper script to show rolls using the roll engine rather than just showing them as pure text.  The way it works now it doesn't allow you to mouse over, you cant see how it was rolled or any information. I dont know who originally helped me with this, so I can't credit them or anything.  But here is the script.  Is what I am asking for possible or am I just having a fantasy :P on("chat:message", function(msg) {     var cmdName = "!bw";     var msgWhisper = msg.content.slice(cmdName.length);     if(msg.type == "api" && msg.content.indexOf(cmdName) !== -1) {         if(_.has(msg,'inlinerolls')){             msgWhisper = _.chain(msg.inlinerolls)                 .reduce(function(m,v,k){                     m['$[['+k+']]']=v.results.total || 0;                     return m;                 },{})                 .reduce(function(m,v,k){                     return m.replace(k,v);                 },msgWhisper)                 .value();         }               if(_.has(msg,'rolltemplate')) {             sendChat('','/w gm &{template:'+msg.rolltemplate+'}'+msgWhisper);         } else {             sendChat('', '/w gm '+msgWhisper.replace(/\&/g,'&') );         }     } }); Thank you in advance for any assistance.
1479266233

Edited 1479304815
The Aaron
Pro
API Scripter
It is possible but slightly complicated. &nbsp;That looks like something I would have written, probably 2 years ago or so. &nbsp;I can probably help with that at some point, but right now I'm beat and headed for bed. If you want to tackle it yourself (or someone else does), the place you need to modify is where it says: m['$[['+k+']]']=v.results.total || 0; You'll need to replace the stuff on the right of the = with something that will show what was rolled. &nbsp;You'll have to parse the roll structure, which is quite daunting. &nbsp;See:&nbsp; <a href="https://wiki.roll20.net/API:Chat#Chat_Events" rel="nofollow">https://wiki.roll20.net/API:Chat#Chat_Events</a> When you have the thing you want to show, you'll use something like: ='&lt;span class="inlinerollresult showtip tipsy" title="'+someFormula+'"&gt;'+v.results.total+'&lt;/span&gt;'; The tipsy classes are what cause it to have the tooltip, the title contains the thing that's displayed. Hope that helps someone (like Scott C. who wants to mess with this stuff anyway...).
1479303224
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
This is such a fun script for thieves.....&nbsp; Thief: I check for traps. GM: Blind roll for detect traps. Thief: [blind rolls] GM: Seems perfectly safe to you. Thief: .... I step to the side and &nbsp;say to the rest of the party "After you."
1479303474
The Aaron
Pro
API Scripter
Hahahaha.. "This is a teachable moment." &nbsp;=D
1479304293

Edited 1479304327
Jakob
Sheet Author
API Scripter
Do you have to parse the roll structure? For a less challenging way, why not just use the expression property, like ='&lt;span class="inlinerollresult showtip tipsy" title="'+v.expression+'"&gt;'+v.results.total+'&lt;/span&gt;'; You don't get to see the actual dice rolled, but it's a start. If you want to get the full tooltip easily, you can kind of cheat by replacing inlinerolls with their expression, i.e. = v.expression This will actually roll everything again when it's whispered to you (but this doesn't work with @{selected} - without some extra work - or with roll queries). Of course, these are not the same rolls as the ones sent out by whoever initiated the command, but since those are never seen anyway, this is more of a religious matter than an actual problem. This is all untested, I probably made a mistake somewhere.
1479304723

Edited 1479304806
The Aaron
Pro
API Scripter
That's not a bad idea! &nbsp;I think it would be: m['$[['+k+']]']='[['+(v.expression||0)+']]'; In particular, since inline rolls are initiated on the client, if the player making the roll was using 3d Dice, they'd see what was rolled even though they'd not see the final calculation. &nbsp;Doing it this way would prevent that sort of "accidental player knowledge". &nbsp;=D Try this: on("chat:message", function(msg) { &nbsp; &nbsp; var cmdName = "!bw"; &nbsp; &nbsp; var msgWhisper = msg.content.slice(cmdName.length); &nbsp; &nbsp; if(msg.type == "api" && msg.content.indexOf(cmdName) !== -1) { &nbsp; &nbsp; &nbsp; &nbsp; if(_.has(msg,'inlinerolls')){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msgWhisper = _.chain(msg.inlinerolls) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reduce(function(m,v,k){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m['$[['+k+']]']='[['+(v.expression||0)+']]'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return m; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },{}) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .reduce(function(m,v,k){ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return m.replace(k,v); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },msgWhisper) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .value(); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(_.has(msg,'rolltemplate')) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('','/w gm &{template:'+msg.rolltemplate+'}'+msgWhisper); &nbsp; &nbsp; &nbsp; &nbsp; } else { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sendChat('', '/w gm '+msgWhisper.replace(/\&/g,'&') ); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } });
Yay! &nbsp;It worked, so far. As for 3d dice, my character sheet design doesn't support them since my attack macros use complicated [[0d0]] rolls to show/hide attack rolls based on base attack on roll templates. Every time a person rolls to attack it basically rolls 15 times for EACH attack. &nbsp;the attack roll the damage roll the confirmation roll and the +damage for crit. &nbsp;It is an old style design to get around early limitation of not having logic. &nbsp;So yah.. rolling 3d dice.. causes most machines to go kinda bonkers. &nbsp;Not to mention the rolls used for auto-calc fields that I never converted to sheet workers because of the lack of !api -&gt; sheetWorkers support. &nbsp;But that part is being fixed... YAY. Anyways, sofar, thanks.
1479328241
The Aaron
Pro
API Scripter
Good deal!
1479366411

Edited 1479366432
Toby
Pro
Well, after testing it, I have found that I can't use it as the changes are incompatible with my roll templates. The one on the left shows how the original API functioned and the one on the left shows how the new version functions. &nbsp;What I gain in roll visibility I lose in how it is positioned. The DC/mod tables are executed using a !bw command as a second roll template joined by the macro text. &nbsp;The DC/Mod ALWAYS uses blind whisper so that is never seen by the players. &nbsp;However, I have a selection box on the character sheet that selects if the roll is OPEN, Whispered or Blind. It works fine so long as it is whispered or open, but the moment I switch it to blind, everything goes to pieces. My guess is that because chat is an Async command, it is getting confused about the order in which they are supposed to be sent. &nbsp;But, I could be entirely wrong (I hope I am wrong cause that is seven different flavors of annoying). Whatever the cause, is there any way to enforce the order without relying on wonky CSS positioning magic to physically rearrange the position of chat elements? &nbsp;I've done that for some things, and it is a pain, though it is fairly consistent in how it positions elements.
1479393916
The Aaron
Pro
API Scripter
Unfortunately, you're correct about the async nature of chat. &nbsp;So I'm guessing your macro is something like this: !bw some stuff &{template:....}{{ ... }} ...
1479396150

Edited 1479396307
Toby
Pro
@{Acrobatics-style} @{Acrobatics-macro} @{Acrobatics-HMod-show} is the Code that gets shunted to the chat... expanded it looks something like: !bw &{template:35Adv_check} @{acrobatics-cond} {{name=@{displayName}'s}} {{check=Acro Check}} {{skill_chk=[[1d20 + @{Acrobatics}]] }} {{infolink=<a href="http://www.d20pfsrd.com/skills/acrobatics" rel="nofollow">http://www.d20pfsrd.com/skills/acrobatics</a>}} {newline} !bw &{template:35Adv_dcinfo} @{acrobatics-dc} @{acrobatics-mod} @{Acrobatics-style} holds the prefix information from the selection box. &nbsp;Either "&nbsp;", "/w gm" or "!bw" @{Acrobatics-macro holds the macro itself &{template:35Adv_check} {foo} @{Acrobatics-HMod-show} is a checkbox to turn on or off the display of 35Adv_dcinfo roll template. I don't suppose there is any way to force the correct order of execution? &nbsp;Without having in the script hold everything from the macros.
1479398213
The Aaron
Pro
API Scripter
Not without some shenanigans. You'd have to introduce some kind of output caching system with order tracking which would wait for earlier messages to be displayed before allowing later ones. &nbsp;Honestly, that idea is very similar to a Gap Recovery System I wrote for a Stock Exchange Normalization System feeding Algorithmic Trading. &nbsp;=D &nbsp;This is probably a lot easier though...
Don't suppose it could be split into two by adding a delay of say.. 3ms. &nbsp;Split it into !bw1 and !bw2 have the second one delayed in its execution just long enough for the first one to fire..
1479399066
The Aaron
Pro
API Scripter
I thought about that (my idea was !bw[#] to introduce a delay of #), but there's waste in doing it that way and you're still not guaranteed proper ordering. &nbsp;Also, that seems like it would only be marginally easier than an ordered output system.&nbsp;
1479418193
Gen Kitty
Forum Champion
You might look into Powercards for this, as it has blindrolling build into it and I used it extensively when I as actively gaming (and will use it again when I return to gaming in the future).&nbsp; I'm not a coder and I'm not seeing what the error is here and why it isn't working, but maybe the two of you will be able to look at the code and see if Powercards is doing anything different that you can emulate :)
I have my own custom roll templates that I like very much. &nbsp;I also want my roll templates to function as independent of the API server as possible. &nbsp;The way I have it set up now, if the API server goes down, my campaign can run "mostly" without issue. &nbsp;If I went that route I'd have to figure out how to add my styles to power cards, and learn how convert ALL of my character sheets to them, which I have 200+ tucked away in 3 storage games. &nbsp;(vault has no sorting). &nbsp;At the moment, I don't have time for either of those. As for looking at the power cards api, I'm not a coder, I haven't a clue what I'm doing with javascript and I break stuff more often than I fix them when it comes to even playing around with SheetWorkers. &nbsp;And thats about as basic as you can get on r20 with js. However, it does have definite &nbsp;advantages, I have often thought about what I might be able to do if I was able to convert my sheets to powercards.