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

[suggestion] add an object to pull the target of a whisper as defined by the whisper, not the _displayname of the player

basically, requesting that the API be able to pull the name of the CHARACTER that was whispered. this would help greatly in adding a script that I would like to write that allows characters to whisper to a set language, and then have a line sent to chat to let players know that someone is actually saying something, even if they can't understand it. example:  /w elvish i'm am speaking in elvish, and if you can understand me, then you can speak it too. output: (from <character speaking>):  I am speaking in elvish, and if you can understand me, then you can speak it too. system: <character speaking> says something that sounds elvish to your ears... 
That would be incredibly useful - for a Diplomacy game I've got it would make the rules whispers really easy to read- "France - attack Belgium" "England - Support Belgium" etc
Maybe we've been going about this the wrong way. For queries like that, it'd probably be best to use a !w command. If you have it so that on chat !w "playername":message it would work. It'd be difficult for characters since you'd need their exact n ame, but for languages and countries it should be fairly easy. You could then just remove the !w, split the message at the : and resend the whisper via the console.
yes, that WOULD be easier, but I would like to have to be able to work with normal whispers, but thats for the players sake. They never remember to use !r to roll dice either, i doubt they'd remember for whispers :)
1377658443
Lithl
Pro
Sheet Author
API Scripter
on('chat:message', function(msg) {     if(msg.type == 'whisper')     {         log(msg.target_name);     } }); /w gm test => GM /w brian test => Brian /w system test => GM (if the character SYSTEM has no controlling players) /w system test => SYSTEM (if the character SYSTEM has one or more controlling players)
That's the tough thing we came across yesterday. We have no clue if it came out to a specific player who happens to speak elven, or if the creature was speaking elven...
1377719025
Lithl
Pro
Sheet Author
API Scripter
If target_name is "GM", then the whisper was sent to the GM specifically, or it was sent to an NPC (a character with no controllers). If target_name matches the displayname of a player, the whisper was sent to a player directly. If target_name matches the name of a character (even if it's a "character" used for multilingual purposes), the whisper was sent to a character directly. I'm not sure what you mean by "We have no clue if it came out to a specific player who happens to speak elven, or if the creature was speaking elven." If msg.target_name is "Elven" then msg.who is speaking in Elven.
eh, if a character is assigned multiple journal entries, as well as journal entries visable to multiple characters, the use of msg.target becomes irrelivant as it's impossible to tell if the message was intended for the player or the journal entry.
1377748195
Lithl
Pro
Sheet Author
API Scripter
Emile l. said: eh, if a character is assigned multiple journal entries, as well as journal entries visable to multiple characters, the use of msg.target becomes irrelivant as it's impossible to tell if the message was intended for the player or the journal entry. But msg.target_name is much better in this instance than msg.target, since msg.target gives the list of playerids who speak Elven, while msg.target_name gives the name "Elven". Would you rather parse a list of IDs and figure out what language(s) those players have in common (and what would you do if they all share two languages?), or would you rather simply look at the fact that they're whispering in elven? ~_^
and msg.target_name is exactly what this thread has been searching for XD you're our hero brian.
1377757003

Edited 1377757394
Lithl
Pro
Sheet Author
API Scripter
o.O target_name was the property I was talking about in my first post in this thread... BTW, I have updated the wiki's documentation to include target_name (as well as playerid, selected, and inlinerolls, which weren't previously documented)