We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
Accept
Advertisement Create a free account

Card Deck images via API.

1553761919

Edited 1553761985
DXWarlock
Pro
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
Forum Champion
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
Pro
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.