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 Deck images via API.

1553761919

Edited 1553761985
DXWarlock
Sheet Author
API Scripter
I'm trying to automate Crit/Fumble decks from the marketplace. I have all the scripting done for the actual finding the inlinerolls in the template sent to chat and seeing if its a crit or fumble. But looking into the API documentation, I cannot for the life of me figure out how (or if) you can get a deck, pick a random card, and pull its image URL. I don't need to deal it to a player, or put it on the tabletop. I just need the image of the card to use in the sendchat part. Can this be done?
1553773643

Edited 1553773699
The Aaron
Roll20 Production Team
API Scripter
Yes. Similar to attributes and characters, there are cards and decks . You can find the deck with the name you are interested in, then find the cards with that deck id, then pick from them randomly. Card.get(‘avatar’) will yield the card image. 
1553797754

Edited 1553797812
DXWarlock
Sheet Author
API Scripter
Thanks man, I eventually got it sorted out. (well, I stole some code from one of your scripts, and another I found for deck/rolltable usage :) ) I was having trouble figuring out how to pull the card objects, from a deck object. I could see they was both API objects in the wiki, just not how they was linked to get one from the other.