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

[API] Get selected token for Deck cards

Hi! I'm trying to automatize some the gameplay of a spanish LCG game to propose its inclusion on the marketplace, and I need some help. What I'm trying to archieve: Using a macro button, identify the selected card (token) and move it in the page. The problem: I don't know how to figure wich is the selected card. The {selected} command doesn't work, I gess that becouse that token represents no character sheet.
1445368957
Lithl
Pro
Sheet Author
API Scripter
A card placed on the tabletop is no different from any other graphic. They default to being drawings rather than tokens, but that can be changed from the context menu.
But I need somehow to get the card and manipulate it on an api script.
1445375386
Lithl
Pro
Sheet Author
API Scripter
If you're using the API, graphic objects which are cards have a "cardid" property telling you which card object it represents. The msg parameter to the callback function of a chat:message event also includes a "selected" property which is an array of all objects you were selecting when you sent the message.
Ty very much Brian, it helped me a lot. Another thing; there's any way to get all the players id's in the campaign from the api, other than sending a chat command and picking sender id?
1445418809
Lithl
Pro
Sheet Author
API Scripter
var allPlayers = findObjs({ type: 'player' }); That will get you all players currently logged in to the VTT . There is no direct means of getting all players in the campaign (including the ones not currently online), although I suppose you could store that information in state.
1445424403
The Aaron
Pro
API Scripter
Brian said: var allPlayers = findObjs({ type: 'player' }); That will get you all players currently logged in to the VTT . There is no direct means of getting all players in the campaign (including the ones not currently online), although I suppose you could store that information in state. Minor correction, that will be all the players that have logged into the Game's VTT. (There is an online properly which tells you if they are currently in the VTT. 
Awesome! Ty guys, very fast reply as allways. Much needed for a Js noob developer like me :D