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

Convert card to token when played?

A couple people suggested that I may be able to address on of the problems I'm having in Roll20 by using the API. I have a tile-laying game, and I'm using a deck of cards for the tiles that works quite well. The one issue is that when a card is played on the table, it is a "drawing" which means it does not snap to the grid. (This is especially troublesome for rotating the card.) If I right-click on the tile and click "Is Drawing" to convert it from a drawing to a token, then it snaps to the grid. But that's a lot of work to ask my players to do. With the API, can I capture when a card is played to the table and then change it to a token?
1402446903
Lithl
Pro
Sheet Author
API Scripter
Yes: on('add:graphic', function(obj) { if (obj.get('subtype') == 'card') { obj.set('isdrawing', false); } }); Note that this will also make the card resize to a near-appropriate number of squares (eg, the default playing card deck will become a 2x2 instead of the ~1.5x2.1 it is as a drawing). Also keep in mind that the API can only be used if the campaign owner is a Mentor.
Perfect. Thanks! I will be upgrading my account to Mentor to give this a try.
Awesome Randy & Brian! I just came to the forum to ask this question. I too just made a tile-laying game and this was exactly what I needed. Works like a charm.
I finally had a chance to try this out, and it works perfectly. Thank you!