Duel.SelectMatchingCard
Signature
Duel.SelectMatchingCard(int sel_player, [function|nil f], int player, int s, int o, int min, int max, [Card|Group|nil ex], ... any) -> Group|nilDescription
Lets sel_player choose min to max cards from the specified locations that satisfy filter f and are not excluded by ex. s is player's own location mask and o is the opponent's location mask from that player's viewpoint. Extra arguments after ex are passed to f. This does not register official Chain targets; use Duel.SelectTarget for card text that targets.
How To Use It
Use this when the selected cards do not need to become official effect targets.
A common pattern is to check with Duel.IsExistingMatchingCard, select with Duel.SelectMatchingCard, then move or modify the selected group during the operation:
local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp)
if #g>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
endUse Duel.SelectTarget in a Target callback when later resolution must re-check tc:IsRelateToEffect(e) or when the card text says the effect targets. Use Group.Select when you already built a Group and only need the player to choose from it.
Related Functions
Parameters
sel_playerint- Player who makes the selection; invalid players make the core return no values.ffunction|niloptional - Filter callback; nil accepts cards that pass location and exclusion checks.playerint- Reference player for the s and o location masks.sint- Location mask on player's side.oint- Location mask on the opponent's side from player's viewpoint.minint- Minimum number of cards to select.maxint- Maximum number of cards to select.exCard|Group|niloptional - Card or Group excluded from selectable cards; nil excludes nothing....any- Extra values forwarded to f after the candidate Card.
Returns
Group|nil- New Group containing the selected cards, or nil if sel_player is invalid.
Source
D:\Programs\GitHub\ygopro-core\libduel.cpp:4973
Guided Examples
Learn how to use this function in context:
- Beginner Script Ladder
- Client UI And Prompt Behavior
- Common Script Errors And Debugging
- Filters, Card Objects, and Group Objects
- Selection And Group Handling
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 5452 indexed script(s).
- Search this function in the Script Explorer with
Duel.SelectMatchingCard.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.lua
Duel.BreakEffect()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
local g=Duel.SelectMatchingCard(tp,s.posfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.HintSelection(g)
local tc2=g:GetFirst()Astrograph Sorcerer, the Starfrost Magician (48171151)
Source: Scripts/c48171151.lua
if Duel.Destroy(c,REASON_EFFECT)==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD)
local g=Duel.SelectMatchingCard(tp,s.pfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,tp)
local tc=g:GetFirst()
if tc and Duel.MoveToField(tc,tp,tp,LOCATION_PZONE,POS_FACEUP,true) thenArtmage Non-Finito (74631897)
Source: Scripts/c74631897.lua
function s.setop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
local g=Duel.SelectMatchingCard(tp,s.setfilter,tp,LOCATION_DECK,0,1,1,nil)
local tc=g:GetFirst()
if tc then