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

Edited Dealer- Tarot Cards Won't Rotate

1743693306

Edited 1743694046
I modified the Dealer script a la @keithcurtis to play cards to the table and post in chat a blurb when a specific card is drawn. I have arrays with the IDs of each card, and then corresponding arrays for the description and the inverted&nbsp; description, since tarot cards mean something different when they're upside down. Everything works, including the coin flip to decide if a card is inverted... except grabbing the card object on the table and actually rotating it. I'm not sure why at this this point. The screenshot is the important part and then the whole gist is included as well. I'm not very good at coding, so be gentle. :b <a href="https://gist.github.com/CarmaNayeli/0f31455cac2ec5da6cbcc60333583832" rel="nofollow">https://gist.github.com/CarmaNayeli/0f31455cac2ec5da6cbcc60333583832</a>
1743716389

Edited 1743716408
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Carmabella! "Not very good at coding" describes me to a tee. It takes me forever to write a script, and this was one of my first. I haven't tested, but I think the problem might lie in the type.&nbsp; You are getting an object of type "card". I believe this refers to a card in a deck. You are trying to flip the card once it is played. Now that it is on the tabletop, it is type "graphic" with subtype "card". A different object. You'll need to get the id of that object if you want to perform transformations on it. This is a guess. Like I said, I haven't tested.
1743716559

Edited 1743854374
timmaugh
Forum Champion
API Scripter
The cardid property represent the card exemplar... ie, THE "The Lovers" card. Once you play the card to the table, what you see on the VTT is a graphic object with a subtype = card and a cardid equal to the ID of the exemplar. If you want to rotate something on the board, you want the ID of THAT graphic object. Here's some code to return all instances of a card- graphic on the user's page that are connected to a specific cardid you supply: const getPageForPlayer = (playerid) =&gt; { &nbsp; let player = getObj('player', playerid); &nbsp; if (playerIsGM(playerid)) { &nbsp; &nbsp; return player.get('lastpage') || Campaign().get('playerpageid'); &nbsp; } &nbsp; let psp = Campaign().get('playerspecificpages'); &nbsp; if (psp[playerid]) { &nbsp; &nbsp; return psp[playerid]; &nbsp; } &nbsp; return Campaign().get('playerpageid'); }; const getCardOnVTT = (cardid, playerid) =&gt;&nbsp; findObjs({ type: 'graphic', subtype: 'card', pageid:&nbsp; getPageForPlayer(playerid) , cardid: cardid})[0]; You'd call it with someting like: let cardGraphic = getCardOnVtt(cardid, msg.playerid); Also, Roll20 exposes a rollInteger() function that lets you use their Quantum Die Roller to generate numbers with significantly less modulo bias. In your case, instead of your Math operation, just assign your variable to the result of this function: let ranNum = rollInteger(2); And, finally, if you want to see how these objects relate to each other, or you need to take a deep dive on an object's properties, consider using my Inspector script . It would let you flow from one panel of information to another. For instance, a good place to start would be to select a card on your page, then run: !inspect --selected Then hit the little magnifying glass button to inspect the object with THAT ID... from the resulting panel, you can see the object type, subtype, and cardID... From that cardid you could flow to the data panel for the card exemplar... but I think by now you get the point. Inspector can be super useful.
1743717295
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Like I said, I'm an amateur. Timmaugh knows what he's talking about. I.e. I was right, but he was righter .
1743723023
timmaugh
Forum Champion
API Scripter
Oh! I walked away never knowing I'd been ninja-fied! But now you have been Keithed. Go, and be excellent to one another. =D
1743801730

Edited 1743804767
I called it like that and then tried to rotate the resulting object and it's saying cardObj.set() is not a function, which leads me to think it's not pulling an object exactly, so I'm confused.&nbsp;
Thank you both very much for the help though! You're super appreciated.
So upon inspecting a card already played to the table, I found the _cardid is the same, and type: graphic, subtype: card are the same. So I'm still not sure why I can't pull the object with findObjs()?
This is the error message, if that helps:
I've been fiddling with it and I think the issue is that getCardonVTT() isn't actually finding the cards for some reason. I can't get *anything* to return from the array.
So for *WHATEVER REASON* it works when you don't specify playerid or subtype. Runs perfectly for me at least, will have to test it with multiple people, but since card are individual per deck, I don't think it will be a problem.
1743854721
timmaugh
Forum Champion
API Scripter
Hmm... the function works for me but I do see now that I left it returning the *array* of potential matches to your search criteria rather than a single card. I built it this way before you mentioned that the cards would be unique, so I was imagining that there could be multiple cards that would match the given parameters. Of course, I should have had the assignment to the variable designate that we wanted the *first* such card in the array... something like: let cardGraphic = getCardOnVtt(cardid, msg.playerid)[0]; ...so that's my fault. But that could definitely be why you were getting the "no function called set" attached to that object... you were still pointing at the array. In any case, I modified the code, above, to account for this. Given that your need was a single card, I altered the function rather than the variable assignment. That is, I put the selection of the first card returned from the findObjs() operation in the getCardOnVTT function rather than requiring it every time you assigned the result to a variable, so now that function should return either a card (if it found one) or undefined.