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 Request: Hidden Whispers

November 17 (10 years ago)
Toby
Pro
I am looking for a script that will allow my players to whisper a result of their roll and have it only display to the GM (or other target of the whisper) and NOT display the result to themselves.

For instance If I do an script that has includes a check against a target token's AC and then Spell Resistance and then a Reflex Save. I dont want them to see by proxy a token's statistics.

I know I have seen two scripts like that before, but after trying both of them neither of them worked. I am hoping for something straight forward and simple, it also needs to support inline rolls otherwise it is kinda useless obviously.

like /hw _name_ the text of the whisper goes here.
November 17 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Here's one that has been circulating about for a while:
on("chat:message", function(msg) {
    var cmdName = "!broll ";
	var msgTxt = msg.content;
	var msgWho = msg.who;
	var msgFormula = msgTxt.slice(cmdName.length);

	if(msg.type == "api" && msgTxt.indexOf(cmdName) !== -1) {
		sendChat(msgWho, "/gmroll " + msgFormula);
		sendChat(msgWho, "/w " + msgWho + " secret roll sent to GM (" + msgFormula + ")");
  	};
});
November 17 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
There might be some cleaner ones, but that gets the job done. You call it like this:

!broll 1d20+7
November 18 (10 years ago)

Edited November 18 (10 years ago)
Toby
Pro
Yeah, this doesnt really work for what I need. I want something to function like a whisper does /w XXX but hide the text from the user. With the above script it doesnt seem like I can call values from the journal.

This is the code I have:
[CODE]
/em @{character_name}'s (@{weapon1name})
!broll @{spacer} Target: AC:[[@{target|armorclass}]] TCH: [[@{target|touchac}]] FF: [[@{target|flatac}]]
@{weapon1critmin}-20 @{weapon1critmult}x @{weapon1range}ft @{weapon1ammunition} shots left
Opt:
@{weapon1fullattackmacro}
-------------------------------------------
@{weapon1damage}
[/CODE]

This is what comes out:

(From Toby (GM)):(GM) secret roll sent to GM ( Target: AC:$0TCH: $1FF: $2)

and it doesnt even continue displaying after that...


What it should display is the following:

Or at least thats what I want it to display more or less.

November 18 (10 years ago)

Edited November 18 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Ah, I misunderstood what you wanted to send. The script I posted works like /roll. Even so, it would print out what the attributes were and obscure the roll. I hacked this together from that script for you:
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();
		}        
		sendChat('Blind Whisper From: '+msg.who, "/w gm "+msgWhisper);
  	};
});

If you change your macro to this, it should do what you want:
/em @{character_name}'s (@{weapon1name})
!bw @{spacer} Target: AC:[[@{target|armorclass}]] TCH: [[@{target|touchac}]] FF: [[@{target|flatac}]]
@{weapon1critmin}-20 @{weapon1critmult}x @{weapon1range}ft @{weapon1ammunition} shots left
Opt:
@{weapon1fullattackmacro}
-------------------------------------------
@{weapon1damage}
November 18 (10 years ago)

Edited November 18 (10 years ago)
Toby
Pro
Thank you very much, this is great. Exactly what I was looking for, although is there a way to strip out the targeting message so it seamlessly sends the whisper without the " (From Blind Whisper From: Toby (GM)): "

Or is that not possible.

Edit: Hrm.. it seems to be placing the whisper at the bottom, is that normal?
November 18 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Regarding Stripping the whisper, this version will have nothing in that preceding area, which is probably as close as you can get to stripping it:
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();
		}        
		sendChat('', "/w gm "+msgWhisper);
  	};
});





As for message order, that's an unfortunate side effect of mixing chat and API chat. Since all messages are processed asynchronously, ordering is not guaranteed. Usually, you won't see this as your chat messages will get processed synchronously (but might be interleaved with other peoples chat messages depending on when they sent them, latency between connections, etc.). However, when you have an API message, it must go through additional processing beyond the chat system, and thus takes longer. Effectively an API command is a chat message that then triggers a chat message:
CHAT MESSAGE 1
CHAT MESSAGE 2
API COMMAND 1
CHAT MESSAGE 3
CHAT MESSAGE 4
[API ISSUED CHAT MESSAGE 1]
It's not avoidable, though you could conceivably replace all your regular chat messages with API chat messages and get the ordering right. Here's a version of the above that just sends a message to chat using !say :
on("chat:message", function(msg) {
	var cmdName = "!say";
	var msgSay = msg.content.slice(cmdName.length);

	if(msg.type == "api" && msg.content.indexOf(cmdName) !== -1) {
        	if(_.has(msg,'inlinerolls')){
			msgSay = _.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);
				},msgSay)
				.value();
		}        
		sendChat(msg.who, msgSay);
  	};
});
You could try it with this:
/em @{character_name}'s (@{weapon1name})
!bw @{spacer} Target: AC:[[@{target|armorclass}]] TCH: [[@{target|touchac}]] FF: [[@{target|flatac}]]
!say @{weapon1critmin}-20 @{weapon1critmult}x @{weapon1range}ft @{weapon1ammunition} shots left
!say Opt:
!say @{weapon1fullattackmacro}
!say -------------------------------------------
!say @{weapon1damage}


You could even replace that /em with this !emas script I wrote a while back to try this: https://gist.github.com/shdwjk/42f34ecfd167ec56c9f7
November 18 (10 years ago)
Toby
Pro
The stripped whisper still has the (From ): prepending the text.
November 18 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Yeah, no way around that unfortunately.

(Though I have a suggestion that would let us do it: https://app.roll20.net/forum/post/1241882/api-slas... )