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 .
×

[Bug] Playing a Card Fires Multiple Events

When playing a card from a deck to the table the api is firing events for both adding a graphic as well as adding a card. Both use the same id and the object with that id has a type of "graphic". Below is the code used. It is the only API script on the campaign. "use strict" ; on ( "ready" , function main () { function eventHandler ( eventName ) { on ( eventName , function ( object ) { log ( ` $ { eventName } : $ { object . get ( "type" )} $ { object . id } .` ); }); } eventHandler ( "add:graphic" ); eventHandler ( "add:card" ); eventHandler ( "destroy:graphic" ); eventHandler ( "destroy:card" ); }); Below is the console output that playing a card from the Playing Cards deck and deleting it from the tabletop produces. "add:graphic: graphic-ME211zEu6v90jewkMQW." "add:card: graphic-ME211zEu6v90jewkMQW." "destroy:graphic: graphic-ME211zEu6v90jewkMQW." "destroy:card: graphic-ME211zEu6v90jewkMQW."
1596716905
The Aaron
Roll20 Production Team
API Scripter
That isn't a bug, it's a feature. Cards that are played to the table are graphics with a subtype of card. The same happens for graphics and tokens. 
1596732732

Edited 1596733575
Does that mean that the following events are fired too (for tokens)? Edit; yes they are! Interesting. Shame that the card events are also fired for legitimate card changes (in the deck) too. Darn naming conflict. Is this documented anywhere? on ( "add:token" , handler ); on ( "destroy:token" , handler );