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

change:message triggered twice?

1455717887

Edited 1455720422
I have a simple eventhandler registered as on('chat:message', handleInput); and when i write in the chat and press enter the handleInput function is called twice? Is there a way to prevent that? Is that normal? Edit: The title is obviously wrong, sorry about that. Edit: I used a variable var registered = false; and  var registerEventHandlers = function() { if(!registered){ on('chat:message', handleInput); on('change:token', handleToken); } registered = true; }; on("ready",function(){ 'use strict'; Shadowrun.CheckInstall(); Shadowrun.RegisterEventHandlers(); }); Too check and now the eventHandlers are only registered once. Still I don't get why RegisterEventHandlers() is called twice.
1455720275
The Aaron
Pro
API Scripter
Can you post the full script?  It's hard to say without seeing it what is actually going on.  Probably you're inadvertently registering your on 'chat:message' handler more than once.
1455720451

Edited 1455720536
Here is a link to the full script and the EventHandlers are registered twice but I don't get why. <a href="https://gist.github.com/anonymous/3f9b0bfc3af652a" rel="nofollow">https://gist.github.com/anonymous/3f9b0bfc3af652a</a>... Edit: now with the registered variable test they are registered only once but I am sure this should not be required.
1455722962
The Aaron
Pro
API Scripter
Is it possibly you have two copies of the script in your API?
1455726730

Edited 1455726778
This was the problem :) I hate it that the selected tab sometimes changes. I accidentially copy/pasted the script over a different script that way!
1455731784
The Aaron
Pro
API Scripter
I can't count the number times I've done that. It happens on changes to enabled. Just have to remember to click back on your script when you click the enable/disable button.&nbsp;