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

Rotating a card on placement to table

Hello. I've written a script that places cards to the table using the playCardToTable function, but there doesn't appear to be an option to rotate the graphic on placement, and there doesn't seem to be a logical event to hook into that would allow me to do this immediately after the placement. According to the forum post here&nbsp; <a href="https://app.roll20.net/forum/post/6223396/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6223396/slug%7D</a> , the only options available are as follows: { left: X position in pixels. Defaults to the center of the page. top: Y position in pixels. Defaults to the center of the page. width: width of token in pixels. Defaults to the deck's defaultwidth, or to 98 if the deck has no default. height: height of token in pixels. Defaults to the deck's defaultheight, or to 140 if the deck has no default. layer: the layer the token will appear on. Defaults to the objects layer. pageid: the page the token is played to. Defaults to the current player page. isdrawing: whether to treat the token as a drawing. Uses the deck "treatasdrawing" as the default. currentSide: whether the card is played face up or face down, with 0 being face up and 1 being face down. Defaults to the deck's default setting. } If anyone knows a way to do this, please share, otherwise, I suppose this could be treated as an API request. Thank you in advance.
1586790572
The Aaron
Roll20 Production Team
API Scripter
You are correct.&nbsp; I brought this up with the devs a while back, I'm hoping we'll get that option at some point. In the interim, you probably need to just set a timeout function to to find your card and do the rotation, something like: const rotateMyCard = ()=&gt;{ let cardOnTable = findObj({type:"graphic",subtype:"card", cardid: card.id, left: x, top: y}); if(cardOnTable){ cardOnTable.set({rotation: 180}); } else { setTimeout(rotateMyCard,100); } }; rotateMyCard();
Ah. Didn't think of trying setTimeout (assumed it wasn't allowed for some reason). Thank you!
Before I start a new thread for a related issue, I will post it here as well. Players in this campaign cannot manipulate/move the cards placed to table with that function, only the GM (even if the players use the command, no transform controls appear on click). The cards are drawn directly from the deck and then placed to the table. I find this odd and I can't find any documentation on the issue. I'll post the whole code snippet for reference (I have a command that places the cards to the table on top of some tokens in the GM layer using an iterator). &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alias : &nbsp; "placeCards" , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; regex : &nbsp; /!placeCards\s ([ \w+\d+(?:_90)?,? ] + ) / , &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function : &nbsp; function ( msg ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if &nbsp;( config [ this . alias ]. gmOnly &nbsp;&amp;&amp;&nbsp;! playerIsGM ( msg . playerid ))&nbsp; return ; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var &nbsp; args &nbsp;=&nbsp; this . regex . exec ( msg . content )[ 1 ]. split ( "," ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; args . forEach ( arg &nbsp; =&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var &nbsp; isRotated &nbsp;=&nbsp; arg . includes ( "_90" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var &nbsp; tokenName &nbsp;=&nbsp; arg . replace ( "_90" ,&nbsp; "" ); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var &nbsp; tokens &nbsp;=&nbsp; findObjs ({ _type : &nbsp; "graphic" ,&nbsp; _subtype : &nbsp; "token" ,&nbsp; name : &nbsp; tokenName }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if &nbsp;( tokens . length &nbsp;&gt;&nbsp; 0 ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var &nbsp; token &nbsp;=&nbsp; tokens [ 0 ]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var &nbsp; card &nbsp;=&nbsp; drawCard ( deckId ); &nbsp;&nbsp;&nbsp;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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SendMessageToChat ( config [ this . alias ]. message . replace ( "$PLAYERNAME" ,&nbsp; msg . who )); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
1587048335

Edited 1587048599
You know, now that I think about it, this probably has something to do with graphic. controlledby. Will investigate.
1587049587
The Aaron
Roll20 Production Team
API Scripter
That's exactly right.&nbsp; You need to add "all" to controlledby on the graphic, or specific players' ids.
Yep, that fixed it. And a timeout of 100 seems to be sufficient for the graphic object to be available (though I should add a failsafe to keep checking a few times if it's not). I would guess what would be needed for the API addition to rotate on placement is to generate/reserve the upcoming graphic's GUID immediately when placeCardToTable is called so it could be used for graphic manipulation via the options, or that it just includes a similar timeout functionality. Hopefully that will be added soon, but this workaround will suffice. Thanks for your help, as always.
1587051353
The Aaron
Roll20 Production Team
API Scripter
No problem!