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] Savage Worlds Fright Table

1416099829

Edited 1416307410
Finderski
Pro
Sheet Author
Compendium Curator
So, I decided to cut my teeth on a small script to allow rolling on the Savage Worlds Fright Table from within Roll20. Update: v0.1 -- Initial release with basic functions Update: v0.2 -- Incorporated the changes recommended by The Aaron Features Roll on the Fright Table with output of the result to the Chat Window How to use: The script is called by sending to chat: !fright If there is a modifier required, for example, a Dragon adds +2 to the roll, the command would be: !fright 2 If no number is provided after !fright, the script assumes a 0 modifier. The output will display the 1d20 die result, the modifier, the end result as well as the text description associated with the roll. The Heart Attack result will automatically roll the 1d4 and the 2d6 rolls required and insert the appropriate number of rounds in the text description. Here's the script: <a href="https://gist.github.com/600b0e3fbe96b15e6c07.git" rel="nofollow">https://gist.github.com/600b0e3fbe96b15e6c07.git</a> This is my first attempt, so any input/suggestions people have on ways to make this better, I'm all ears. Also, I'd really like the output to be similar to an emoted or whispered message, only with a different color scheme—is there a way to do that? This script is part of the way there, but the background color doesn't go edge-to-edge of the Chat window the way an emoted or whispered message does. Thanks.
1416188888
The Aaron
Roll20 Production Team
API Scripter
Hi G.V.! Congrats on your first foray into API Scripts. I have to say, I approve of the coding style. =D Since you've asked, I do have a few minor suggestions: • I've been switching my scripts to split arguments on /\s+/ instead of " ". That regular expression will match 1 or more of any whitespace characters (space or tab), so if the user accidentally double spaces between arguments, it will still split into the right places. • I'd suggest whispering the error on line 27. That will prevent the log from being filled with spam by those players trying to figure out what they are doing. =D I like to use this code to get the first name of the message sender (you can't trust the msg.who, because it might be a character instead of a player) and if you just get the name, only the first word is used and the rest appears in the message. (there is a feature for quoting player names, but it does't work with the api yet) var who=getObj('player',msg.playerid).get('_displayname').split(' ')[0]; Then you can do: sendChat(msg.who,'/w '+who+' Too many or wrong type of input. !fright should have at most one integer.'); • I'd suggest using parseInt() instead of Number(). Number supports floating point, which you probably don't want. frmod = parseInt(args[1],10) || 0; Nice script and happy coding!!
1416189974
Finderski
Pro
Sheet Author
Compendium Curator
Thanks for the suggestions! I'll definitely take another pass at revising things to clean it up and care for the problems you highlight. I did try parseint() initially, but kept getting an error--it was likely unrelated, so I'll look at that as well. Thanks again!