We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
Accept
Advertisement Create a free account

[script] What did he say? Updated Script (Complete Overhaul.)

1410487383
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Language Character Record Sheets are added by the API based on the languages created in the API. Use "Speak As" with no commands needed (just start the sentence with a "!".) GM sees all languages on("ready", function() { checkForSheets(); The on("ready", function() checks for the Character Record Sheets and adds them as needed, based on the languages in the script. roll20API.languageData = [ { Description: "Dwarven", Sheet: "Language(Dwarven)", languageSeed: 2, characters: "Dwarven"}, { Description: "Elvish", Sheet: "Language(Elvish)", languageSeed: 4, characters: "Elvish"} ]; Similar langues can use the same "characters" but would have a different "languageseed" . Or you could add more characters: numbers = []; numbers["Standard"] = ["1","2","3","4","5","6","7","8","9","0"]; numbers["Dwarven"] = ["",":","∴","+","◊","◊","◊:","◊∴","◊+","°"]; numbers["Elvish"] = ["",":","∴","+","¤","¤","¤:","¤∴","¤+","°"]; numbers["Minor"] = ["",":","∴","+","×","×","×:","×∴","×+","°"]; numbers["Evil"] = ["",":","∴","+","∏","∏","∏:","∏∴","∏+","°"]; Language Character Record Sheets have a common avatar and are named to be grouped together: Who can speak the language is controlled by the sheet: The process for on("chat:message", function (msg) requires very little code: on("chat:message", function (msg) { // Exit if not an api command if (msg.type != "api") return; //****Check For Language checkForLanguage(msg); // Get the API Chat Command msg.who = msg.who.replace(" (GM)", ""); msg.content = msg.content.replace("(GM) ", ""); var command = msg.content.split(" ", 1); }); To use a language just use the chat "As:" drop down: Just use an "!" at the start of whatever you want to say. &lt;-THIS IS VERY IMPORTANT. For example... Wes who speaks dwarven, would choose "As:" Langue(Dwarven) and enters: "!Who sees my Dwarven?" Wes will see: GM will see: Players that speak Dwarven see: Players that DO NOT speak Dwarven see: GIST below: <a href="https://gist.github.com/BaldarSilveraxe/d66d4aad2f" rel="nofollow">https://gist.github.com/BaldarSilveraxe/d66d4aad2f</a>...
1410490237
This is very nice, a workaround for those who do not have the API. Make a sheet for each language, give control of the sheet to every player who can speak it. Give those players a macro that looks like this: /w Elf ?{what?| "nuthin"} /em Bob is babbling in Elvish!
1410518354
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
I made this a while back on lark when trying to pick up JavaScript.... And was still getting PM about it because my GIST broke. It can be immersive and quite fun... So thought I would fix and restore it.
This new version appears to not play nice with powercard maths unfortunately
1410535138
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Post how you parse your API command.... This should really take any text string following an"!" point. You could put it at that end of your on "chat" and it shouldn't interfere with anything above.
I figured out where I went wrong. I was testing the powercard while still having the speak as set to dwarven. As long as i set that back to speak as myself the powercard works fine. Rookie error :)
1410570775
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
I would still put it below all your commands and "return" after coming back from a command.... then you should not have an issue if you are still in "Dwarven."
1410730892

Edited 1410732045
Oh this looks awesome! I love all the symbols. In my group we use our real names as the ooc names (and our characters have proper portraits and such), so would it be reasonable to make an alternate version that lets you use commands like "!Elvish This is an elvish message" so we can use macro buttons instead of changing "As:"? Being able to use the macro "!?{Language} ?{Words Spoken}" seems the most convenient. Looks like "in mocking " should have a space added to be " in mocking ". (Oh, the GM is the only one that message can show up for anyway.)
1410732231

Edited 1410732537
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
If you add "all players" AND named players that can control to a language sheet..... all players can use the language... but it will only translate for players actually named.... that way the mocking feature works for "all" players not named in the sheet.. and translates for those named in the sheet. Make sense? And yes... you could do what you want with the macro.... it would just be a modification in the ""on chat" event. You would put the command in here.... and modify the msg object before sending to trick it out to think it was "spoken as." on("ready", function() { checkForSheets(); on("chat:message", function (msg) { // Exit if not an api command if (msg.type != "api") return; //****Check For Language checkForLanguage(msg); // Get the API Chat Command msg.who = msg.who.replace(" (GM)", ""); msg.content = msg.content.replace("(GM) ", ""); var command = msg.content.split(" ", 1); }); });
I just used this on Sunday for my group. First off, amazing. After a small hiccup, got it to work, which allowed their characters to curse in another language just so the npcs didnt know. Great for immersion. The problem our group ran into was related to the output. Whenever one of the players who's in-session name(the one that shows under the avatar) does not have a last initial(or possibly a second word) in it, when they tried to use it: 1. Other players(if they had the last initial) received the 'whisper'. 2. The whisper showed up as (From ):Blah blah (a blank space where the name should be) but the body of the message worked fine. 3. The players who didnt have a last initial, did not recieve a whisper, even if they sent it out. I'm not good enough with codes to know whats causing it, but it works great now that I made all the in-session names have a last initial. So I'm not too worried about it for now. Just a heads up. Thanks for this great Script.
1411412979

Edited 1411413018
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Easiest fix to that.... Single name "Display Name." Change the name... its a minor ask from the players and it will make everything work just fine. Found on the setting taps for everyone in the campaign. Its what I do in my campaigns.