Skip to content

Duel.SelectMatchingCard ​

Signature ​

lua
Duel.SelectMatchingCard(int sel_player, [function|nil f], int player, int s, int o, int min, int max, [Card|Group|nil ex], ... any) -> Group|nil

Description ​

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:

lua
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)
end

Use 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.

Parameters ​

  • sel_player int - Player who makes the selection; invalid players make the core return no values.
  • f function|nil optional - Filter callback; nil accepts cards that pass location and exclusion checks.
  • player int - Reference player for the s and o location masks.
  • s int - Location mask on player's side.
  • o int - Location mask on the opponent's side from player's viewpoint.
  • min int - Minimum number of cards to select.
  • max int - Maximum number of cards to select.
  • ex Card|Group|nil optional - 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:

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.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua1
Astrograph Sorcerer, the Starfrost Magician48171151Scripts/c48171151.lua1
Artmage Non-Finito74631897Scripts/c74631897.lua1
Pendulum Evolution55795155Scripts/c55795155.lua2
Levia-Dragoon - Daedalus78579058Scripts/c78579058.lua2
Lady's Dragonmaid48658295Scripts/c48658295.lua1
Azure Ocean Dragon Lord - Neo-Daedalus Rage41570943Scripts/c41570943.lua1
Eternal Favorite87532344Scripts/c87532344.lua1
Astrograph Sorcerer76794549Scripts/c76794549.lua3
Spellbook of the Grand Circle11911336Scripts/c11911336.lua1
Accel Synchro Stardust Dragon30983281Scripts/c30983281.lua2
Ashtraja Susanoo17020474Scripts/c17020474.lua2
Deftero Enneacraft - "alazoneIA"92171126Scripts/c92171126.lua2
El Shaddoll Apkallone50907446Scripts/c50907446.lua1
Mementotlan Fusion66518509Scripts/c66518509.lua2
Meteoroa Drytron24166324Scripts/c24166324.lua2
Gem-Knight Dispersion24220368Scripts/c24220368.lua1
Performage Cup Tricker6812770Scripts/c6812770.lua2
Ehther the Heavenly Monarch96570609Scripts/c96570609.lua2
Ghostrick Renovation61818176Scripts/c61818176.lua1
Pere-Zenet Em Heru46273941Scripts/c46273941.lua2
Am Duazenet45151304Scripts/c45151304.lua2
Magnet Bonding65514302Scripts/c65514302.lua2
Ursarctic Polari27693363Scripts/c27693363.lua2
...and 5428 more

Script Examples ​

Salamandra with Chain (62091148) ​

Source: Scripts/c62091148.lua

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

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) then

Artmage Non-Finito (74631897) ​

Source: Scripts/c74631897.lua

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