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] Language command that garbles text if the character does not know it

I am running a DnD 4e campaign and wanted to allow both myself and players to speak using the languages they know. Instead of using the whisper trick where people wouldn't even know communication was happening, I created a "!speak" command that garbles the message for those that don't speak the language (determined from the character sheet). To try it out just select a token and type "!speak [language] [message]" in the text chat. The gist is linked below, and feel free to leave comments for improvements. <a href="https://gist.github.com/mfajer/838895fd8dad450fb46b" rel="nofollow">https://gist.github.com/mfajer/838895fd8dad450fb46b</a>
What does this script look for to determin if a character or player can speak a language? I am not good enough at API scripts to just look and see what atribute it is checking.
It was using the "lang" attribute, which is what the DnD 4e character sheet dropped the languages in. I went ahead and added that as an easy-to-customize option at the top of the script, though, so you can change it for your favorite game.
1408683558
Lithl
Pro
Sheet Author
API Scripter
It looks for an attribute named "lang", which is a list of languages the character knows. var separators = /[()-\s,]+/; ... getAttrByName(character.id, "lang").split(separators).forEach(function(lang) { if (lang.toLowerCase().match(language)) { log(pc.get("name") + " :: " + language); fluent = true; } }); @UnoPolak: Your regex for separators has a bug. Inside of a character class, the hyphen specifies a range of characters... you're specifying the range ' ) ' to ' \s ' (space), but the closing parentheses character is 0x29 while the space character is 0x20. If you want to include the hyphen in your character class, you need to escape it: ' \- '.
Thanks for the bug fix Brian, updating it now.