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 rollresult message event different since Update of Holding

I notice a subtle change in one of my scripts and would like to know if that is intentional. My script is run on this event handler: on('chat:message', function(msg) { if(msg.type != 'rollresult' || msg.content.indexOf("tn=") === -1) return; // my script stuff ... } I use it to trigger a message about the success of a 3d dice roll if the dice roll is follow by a command like this "tn=4" meaning the target number was 4. Before the Update of Holding my script and the message it prints to the log was run after the 3d dice had stopped. Now I see the message right away. That is a bit annoying because it means that we can see the result in the log before the dice have been rolled. Is there a way to avoid this problem or could it even be considered a bug?
Not sure if it makes a difference, but when an updated occurred two weeks ago, 3D dice stop being triggered by API scripts. This has been noticed and commented on concerning PowerCards specifically.
1428783303
The Aaron
Pro
API Scripter
It probably isn't a bug, just a change in the way notifications happen. I'd suggestion delaying your output by a few seconds to account for it: on('chat:message', function(msg) { if(msg.type != 'rollresult' || msg.content.indexOf("tn=") === -1) return; setTimeout(function(){ // my script stuff ... }, 3000 ); // 3 second delay }
Sean G. said: Not sure if it makes a difference, but when an updated occurred two weeks ago, 3D dice stop being triggered by API scripts. This has been noticed and commented on concerning PowerCards specifically. His script doesn't actually roll any dice via the api, unlike powercards. His script just reads the message, looks for any dice rolls and a specific line of text part of those dice rolls and then spits out some information to chat.
Thanks a lot The Aaron for the idea with the delay! It turns out that it works pretty well, although we are using exploding dice, but the fixed 3 seconds delay still feels about right even if dice are re-rolled a couple times.
1428877084
The Aaron
Pro
API Scripter
Ah, with exploding dice, you could adjust the timeout based on the number of dice requested vs the number of dice rolled. A simple ratio of the requested vs. rolled dice (adjust if you aren't using inline rolls) would probably be sufficient in most cases: var counts = _.reduce(msg.inlinerolls,function(m,r){ m=_.reduce(r.results.rolls,function(m2,r2){ m2.r+=r2.dice; m2.c+=r2.results.length; return m2; },m); return m; },{r:0,c:0}), ratio = Math.ceil(counts.c/counts.r); and multiply your timeout by that.