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

3D Dice Have Stopped Rolling on sendChat

So yesterday, I was happily working on an API and found that while text chat messages for dice rolling were showing up fine and there were no errors in my console, the 3 d dice have stopped rolling from an API.&nbsp; They work as expected when I enter something like /roll 3 d6 in the text chat, but not when my api brings that up. I've checked my Automatically roll 3D dice and it is checked.&nbsp; I've turned it off and on.&nbsp; Still no go. I deleted all my scripts including those from the script library leaving just the dice rolling API I had created with the help of some folks here.&nbsp; Still no 3d dice.&nbsp; The sendChat command still has {use3d: true} as its 4th argument. I'm pretty sure I've done nothing to change the script. Any ideas? Code is (with help from <a href="https://app.roll20.net/forum/post/8951266/request-javascript-criique/?pageforid=8980029#post-8980029on('ready',%20()%20=%3E%20{" rel="nofollow">https://app.roll20.net/forum/post/8951266/request-javascript-criique/?pageforid=8980029#post-8980029on('ready',%20()%20=%3E%20{</a> on('ready', () =&gt; { function checkDice (content) { //First, trim off any spaces. //content=content.trim(); //Now trim out let args = content.split(/\s+/); let numDice = parseInt(args[0]); let numTarget = parseInt(args[1]); let dice = {};//Defines dice as a prpoertytthat can have various values // error checking goes here, and if an error is found, a message string is saved to dice.error //Verify that numDice is a number. if (isNaN(numDice)) { dice.error = '===============&lt;br&gt;**Crossfire Roll Error**&lt;br&gt;' + 'You entered: !cf ' + content +'.&lt;br&gt;The correct ' + 'format is:&lt;br&gt;&lt;br&gt;!cf [no of dice] [OPTIONAL to hit] &lt;br&gt;&lt;br&gt;' + '**Examples**:&lt;br&gt;!cf 3 will roll 3 dice, with 5,6 to hit.' + '&lt;br&gt;!cf 2 6 will roll 2 dice, just a 6 hits (note just a ' + 'space, no comma).'; } // if an error exists, end the function early, so the script can be ended back in the main body. if(dice.hasOwnProperty('error')) { //Do nothing, dice.error has been written. } else { // save the calculated and validated dice values. dice.number = numDice, dice.target = numTarget || 5; } return dice; } function reportHitrange(target) { let range = ''; switch(target) { case 6: range = 'only 6 hits (-1 pip).'; break; case 5: range = '5 or 6 hits (normal).'; break; default: let pips = 5 - target; if (pips == 1) { pips = ' (+1 pip)'; } else { pips = ' (+' + pips + ' pips)'; } range = target + ' to 6 hits' + pips; } return range; } function AreDiceOk(DiceToRoll, DiceToHit) { let DiceMessage = 'OK'; //log('---&gt; DiceToRoll: ' + DiceToRoll + '; DiceToHit: ' + DiceToHit); //Dice range must be from 1 to 9 if (DiceToRoll &lt;= 0) { DiceMessage = 'It makes no sense to specify ' + DiceToRoll + ' dice.'; } else if (DiceToRoll &gt;= 9) { DiceMessage = "You have specified " + DiceToRoll + " dice to be rolled. There is no requirment in Crossfire or " + "Tim's Armour Rules for 9 or more dice to be rolled."; } //log('Checked DiceToRoll: ' + DiceMessage); //log('DiceToHit: ' + DiceToHit); //Now make sure there are 2 to 6 specified in DiceToHit if (DiceToHit &lt;= 1 || DiceToHit &gt; 6) { log('Checked DiceToHit and there is an issure. Before consideration: ' + DiceToHit + ' - ' + DiceMessage); if (DiceMessage !== 'OK') { DiceMessage = DiceMessage + '&lt;br&gt;&lt;br&gt; Also, you '; } else { DiceMessage = 'You '; } log('Checked for preceding DiceMessage Contents: ' + DiceMessage); DiceMessage = DiceMessage + 'have specified ' + DiceToHit + ' or higher to hit.' + ' You can only enter 2 to 6 for the second argument.'; } log('Result: ' + DiceMessage); return DiceMessage; } on('chat:message', function(msg) { //Convert what is typed to lowercase and trim. let chatcommand = msg.content.trim().toLowerCase(); if(msg.type == 'api' &amp;&amp; chatcommand.startsWith('!cf')) { // since 'player|' + msg.playerid is used multiple times, store it a variable. let sender = 'player|' + msg.playerid; // move error checking off into its own function, so it can be handled neatly //trim off !cf. This is required in case the command does not have //a space, for example, !cf4 let dice = chatcommand.replace('!cf',"").trim();//necessary to trim in case of leading space //Pass dice to function checkDice dice = checkDice(dice); // if this returns an error, we have to end the function and report the error. if(dice.hasOwnProperty('error')) { sendChat(sender, dice.error); return;//break out of function. I'm not comfortable with this } else { let DiceOK = AreDiceOk(dice.number, dice.target); if (DiceOK !== 'OK') { sendChat(sender, '===============&lt;br&gt;**Crossfire Roll** (' + msg.content.trim() + ')&lt;br&gt;&lt;br&gt;' + DiceOK); return; } } // if we reach this point numDice and numTarget are valid, and are accessed with dice.number and dice.target // saving the output in its own variable makes the sendChat line neater and easier to read. //With all those commas, the null and the {use3d} part, it would be easy to make a syntax error. This helps avoid that. let hitRange = reportHitrange(dice.target); let message = `=============== **Crossfire Roll** (${msg.content.trim()}) ${dice.number} dice; ${hitRange} /roll ${dice.number}d6&gt;${dice.target}`; //message = `&amp;{template:default} {{name=Crossfire Roll (${msg.content})}} {{Roll=${dice.number}d6; ${hitRange}}} {{Result=[[${dice.number}d6&gt;${dice.target}]]}}`; sendChat(sender, message, null, {use3d: true}); } }); });
1596132651
The Aaron
Roll20 Production Team
API Scripter
3d Dice aren't rolled for API generated chat messages by default.&nbsp; There's an optional setting in sendChat() that turns on rolling them.&nbsp; It's isn't ideal the way it works, but you can play with it.&nbsp; If you look at my Tagmar script, it has the option to roll 3d dice. You can read up on it here:&nbsp;&nbsp; <a href="https://wiki.roll20.net/API:Chat#sendChat.28speakingAs.2C_input_.5B.2Ccallback_.5B.2C_options.5D.5D_.29_.5BAsynchronous.5D" rel="nofollow">https://wiki.roll20.net/API:Chat#sendChat.28speakingAs.2C_input_.5B.2Ccallback_.5B.2C_options.5D.5D_.29_.5BAsynchronous.5D</a> use3d &nbsp;-- You can now generate 3D Dice rolls using the sendChat() function. The syntax is simply:&nbsp; sendChat("Name", "Rolling [[3d6]]", null, {use3d: true}); &nbsp;If you pass a player ID to the name parameter, such as&nbsp; sendChat("player|-ABC123",...) &nbsp;the player's color will be used for the dice. Otherwise a default white color will be used. Note: &nbsp;Clients can only show the result of one 3D roll at a time, so making a bunch of separate 3D rolls in a row is not useful. Also note that using 3D rolls does place a bit more strain on the QuantumRoll server, so use your judgement and don't perform 100 3D rolls in the space of a second. Use 3D rolls when the roll will "matter" to the player and make an impact on the game.
1596132719
The Aaron
Roll20 Production Team
API Scripter
And of course, now that I look at what you said more closely (and the code), it looks like you're aware of the above.&nbsp; Possibly a problem with Roll20... I'll have to try it tonight.
1596169824

Edited 1596177849
The Aaron said: And of course, now that I look at what you said more closely (and the code), it looks like you're aware of the above.&nbsp; Possibly a problem with Roll20... I'll have to try it tonight. I was hoping that might be the issue.&nbsp; As I said, I deleted all scripts except the Crossfire roll I had worked on previously, restarted, and still got the same no dice rolled. :) EDIT:&nbsp; I should also mention this happens in both Chrome and Firefox.&nbsp; We've found Roll20 does not connect multiple players together at all, but Chrome does.&nbsp; Personally, I do all API scripting in Firefox as I really don't like Chrome anymore, I find it very slow. Note also that the "blurp" sound occurs as if dice are being rolled, but the dice do not appear. -- Tim
1596239650

Edited 1596253513
I should also add that I've created a new game and added the following basic script while at the same time ensuring "Enable 3D dice" and "Automatically roll 3D dice" are checked.&nbsp; Still, while the sendChat works in the text chat, but still the dice are not rolled across the tabletop. on('chat:message', function(msg) { if(msg.type == 'api' &amp;&amp; msg.content.startsWith('!testcf')) { sendChat('player|' + msg.playerid, "/roll 3d6", null, {use3d: true}); } });
1596270047
GiGs
Pro
Sheet Author
API Scripter
I just tested the script, and 3d dice are not working for me either.
GiGs said: I just tested the script, and 3d dice are not working for me either. Thanks Gigs.&nbsp; Hurray, I'm not insane! :)
1596322936
Gold
Forum Champion
keep up the good work for the community hope it can be figured out more &amp; faster 3ddice is for the fun!
Gold said: keep up the good work for the community hope it can be figured out more &amp; faster 3ddice is for the fun! Thanks! -- Tim