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

[Dealer] Any way to deal a card to a target token, instead of the selected token?

The thread for [Dealer] has closed so let me know if there's someone else I should contact about this. I wanted to make a macro to give or take cards from a @target player but it looks like it only works for the selected token?
1696524389
timmaugh
Forum Champion
API Scripter
I've poked Keith, the script author, on this to see if the script has a native behavior, but there is a way to do this with metascripts. Install the MetaScriptToolbox, then augment your existing command line by including the syntax: {&select @{target|Pick Token|token_id} } That will turn a targeted token into a selected token for the purposes of your Dealer command (the selection is made virtually -- nothing will change on the VTT). Note, if you want a non-GM to be able to do this in game, you will need to configure SelectManager to allow it. In this case, once the Toolbox is installed (SelectManager is part of the MST), run this command to let players use IDs: !smconfig +playerscanids
Thank you so much for the quick reply, I will take a look at that now!
1696525619

Edited 1696525740
EDIT: Nevermind, figured it out, I had to specify the select argument inside of !deal, not just anywhere inthe Macro. Got it. Thanks!
1696527072
timmaugh
Forum Champion
API Scripter
Yep... it all has to be in the same command line, so no line breaks between the !deal handle and the metascript tags (like {&select} ).
If you happen to get ahold of Keith, it looks like the --take command for the same script is still broken from when it was originally raised. Basically, if you tell the script to --take a named card from a player, it instead gives them that card.
1696537469
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Sigh... I'll have to open the crypt and exhume the code. That was my first script, and I'm always surprised it doesn't have more problems. I'll grab some holy water and take a look.
keithcurtis said: Sigh... I'll have to open the crypt and exhume the code. That was my first script, and I'm always surprised it doesn't have more problems. I'll grab some holy water and take a look. ♥ Thank you very much, it's a very nice tool on its own, but that take functionality would be so good! Appreciate your effort!
1696878278

Edited 1696879162
keithcurtis said: Sigh... I'll have to open the crypt and exhume the code. That was my first script, and I'm always surprised it doesn't have more problems. I'll grab some holy water and take a look. I had a savvier friend than me take a look and these were his comments, if it helps with the official script. I'm trying to test a fix on my local campaign for now and will report back: I think I see it the if (cardChoice !== '') { block starting on line 95 simply doesn't check cardAction at all so the functionality to take a specified card is unimplemented you'd need to add a check for cardAction in the if block similar to the switch at L132, and then implement a similar (but simpler) "find card id, call takeCardFromPlayer" flow with a specific card name instead of "find a card from the right deck" it might be cleaner if you were writing from scratch to unify the "specified card" and "any card from this deck" code paths but right now those are split up at the top level actually, nevermind just add if (cardAction == 'give') around line 106 and put takeCardFromPlayer in the else block with the same args Someone else noted Looks like takeCardFromPlayer uses a different set of parameters than giveCardToPlayer. takeCardFromPlayer(playerid, options(optional) ) giveCardToPlayer(cardid, playerid) which is a bit of a frustrating asymmetry hope this is helpful, still testing their suggestions on my end!
1696880724

Edited 1696880754
Oh my goodness we got it fixed! You may want to test yourself that everything still works, but essentially, you just add this: Replace the section that currently reads //If a card is specified by name if (cardChoice !== '') { let theCard = findObjs({ _type: 'card', name: cardChoice, _deckid: deckID })[0]; if (theCard !== undefined) { do { let specificCardID = theCard.id; giveCardToPlayer(specificCardID, ownerid); numCards--; } while (numCards > 0); return; } else { sendChat('deal', '/w gm There does not seem to be a card named ' + cardChoice + ' in the deck ' + deckChoice); return; } } With this:             //If a card is specified by name             if (cardChoice !== '') {                 let theCard = findObjs({                     _type: 'card',                     name: cardChoice,                     _deckid: deckID                 })[0];                 if (theCard !== undefined) {                     do {                         let specificCardID = theCard.id;                     if (cardAction == 'give') {                         giveCardToPlayer(specificCardID, ownerid);                         numCards--;                     } else {                         takeCardFromPlayer(ownerid, {cardid: specificCardID})                         numCards--;                                             }                     }                     while (numCards > 0);                     return;                 } else {                     sendChat('deal', '/w gm There does not seem to be a card named ' + cardChoice + ' in the deck ' + deckChoice);                     return;                 }             } Tested it and it works for me! Thanks Keith!
1697414125
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thank you! I just tested it and it works great. I incorporated that change, plus a few changes the Aaron posted in another old thread ,that enables it to parse inline rolls. You can also specify a play_id by including:  --ids[player_id] at the end of a command. You can get a list of player ids in the game by typing: !deal --players and full help available by typing !deal --help If anyone wants to test it, you can get the code  here . I'm not submitting a PR yet, just in case something is horribly broken... (Timmaugh's selectManager solutions are great, and probably better and more efficient than what I could write, but I want things to work out of the box as much as possible. I have not yet tackled iterating through multiple tokens/ids.)