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

Card Names?

I am working on a script to audit in chat all card actions. Starting with the basics.... on("change:graphic", function(obj) {       if (obj.get("subtype")=="card") sendChat("System",obj.get("name")+" moved.") }); on("add:graphic", function(obj) {       if (obj.get("subtype")=="card") sendChat("System",obj.get("name")+" placed on table.") }); on("destroy:graphic", function(obj) {       if (obj.get("subtype")=="card") sendChat("System",obj.get("name")+" removed from table.") }); Running into my first thing.... I would think that obj.get("name") should show something like "Six of Diamonds", but, it is blank (just showing " moved.").   Can anyone let me know what I might be doing wrong there?
The obj that you are getting when a graphic is modified is the token object on the table. Currently, the token object itself itsn't assigned the name of the card. However, there is a "_cardid" property which you can use to get the original card object, and you can get the name from that. However, unfortunately I haven't had a chance to add in the code to work with the original Card object yet...so right now all you could do is print the ID of the card. Sorry, that should be coming soon.
Cool, look forward to that getting out there. Looking forward... past the card objects, I did not notice anything that would otherwise "trigger" something on other actions with the card (or maybe more accurately, the "decks")... ie, shuffling, recalling, dealing, etc.  The ultimate goal would be to audit those actions as well.  If I missed something in the API regarding that, let me know.  Otherwise, the addition of general "deck" actions for triggers would be welcomed.