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

Announce DM rolling

1598452753

Edited 1598454839
Hi all, Here's a little something I cobbled together: on("ready", () => {   on("chat:message", (msg) => {     if ("gmrollresult" === msg.type && playerIsGM(msg.playerid)) {       var randText = new Array();       randText[0] = "/desc The DM is rolling. . .";       randText[1] = "/desc You hear the sound of dice rolling";       randText[2] = "/desc The DM rolls dice ominously";       randText[3] = "/desc Dice roll behind the scenes";       randText[4] = "/desc The DM rolls for something. . .";       randText[5] = "/desc You shudder as the DM rolls dice. . .";       randText[6] = "/desc Dice are being rolled by the DM";       var i = Math.floor(randText.length * Math.random());       sendChat("", randText[i]);     }   }); }); Whenever the output of the /gmroll is posted to the chat, it will also post one of the above messages Easily customizable! Add more text? Easy - add a new line and increment the randText Eg: randText[8] = "/desc Some description here"; To remove some of the options - just delete the appropriate number of randText lines, so if you only wanted it to output 2 possible options it would look like: on("ready", function () {   on("chat:message", function (msg) {     if ("gmrollresult" === msg.type && playerIsGM(msg.playerid)) {       var randText = new Array();       randText[0] = "/desc The DM is rolling. . .";       randText[1] = "/desc You hear the sound of dice rolling";       var i = Math.floor(randText.length * Math.random());       sendChat("", randText[i]);     }   }); }); To add it to your roll20, you need to do so manually (also how I would suggest using it, as you can them customize the responses) **Edit** Adjusted, thanks to input from Keith
1598453965
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
How about changing the var i line to: var i = Math.floor(randText.length * Math.random()) Then you wouldn't need to worry about counting the number of responses.
Good shout! Didn't even think of that. I'll adjust the above