Skip to content

Duel.SelectTarget ​

Signature ​

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

Description ​

Lets sel_player choose min to max cards that satisfy filter f, are not excluded by ex, and can be targeted by the currently handled effect. The selected cards are registered as the current Chain's target cards. For non-continuous effects, the core also creates Chain relations used by IsRelateToEffect and related helpers. This requires a current Chain; use Duel.SelectMatchingCard or Group.Select for ordinary resolution choices.

How To Use It ​

Use this in the Target callback of an activated effect that targets cards.

The selected cards are saved as the Chain's targets. This function needs a current Chain; use Duel.SelectMatchingCard or Group.Select for ordinary resolution choices. For one target, read it with Duel.GetFirstTarget and check tc:IsRelateToEffect(e) before applying the effect. For several targets, use Duel.GetTargetsRelateToChain to get the target group that is still related to the resolving Chain.

lua
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
    if chkc then return chkc:IsOnField() and s.filter(chkc) end
    if chk==0 then return Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,0,1,nil) end
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET)
    Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,0,1,1,nil)
end

function s.operation(e,tp,eg,ep,ev,re,r,rp)
    local tc=Duel.GetFirstTarget()
    if tc and tc:IsRelateToEffect(e) then
        Duel.Destroy(tc,REASON_EFFECT)
    end
end

Parameters ​

  • sel_player int - Player who makes the selection.
  • f function|nil optional - Filter called with each candidate card first, then any extra arguments after ex.
  • player int - Viewpoint player for s and o.
  • s int - Locations on player's side to search.
  • o int - Locations on the opponent's side to search.
  • 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 the selection.
  • ... any - Extra values passed to f after the candidate card.

Returns ​

  • Group - Group of cards selected by sel_player and registered as current Chain targets. If there is no current Chain or sel_player is invalid, the core returns no value.

Source ​

  • D:\Programs\GitHub\ygopro-core\libduel.cpp:4986

Guided Examples ​

Learn how to use this function in context:

More guided lessons (6)

Used By ​

Generated from the local Scripts/ folder and cards.cdb.

  • Detected in 5099 indexed script(s).
  • Search this function in the Script Explorer with Duel.SelectTarget.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua1
Pendulum Evolution55795155Scripts/c55795155.lua1
Surprise Fusion35167375Scripts/c35167375.lua1
Ultra Polymerization76647978Scripts/c76647978.lua1
Ashtraja Susanoo17020474Scripts/c17020474.lua1
Fiendsmith's Sequence49867899Scripts/c49867899.lua1
D/D/D Alfred the Divine Sage King11852093Scripts/c11852093.lua1
El Shaddoll Apkallone50907446Scripts/c50907446.lua1
Meteoroa Drytron24166324Scripts/c24166324.lua1
Mixousia the Confounder80843006Scripts/c80843006.lua1
Invoked Sorath43989315Scripts/c43989315.lua1
Performage Cup Tricker6812770Scripts/c6812770.lua2
Spirit Illusion71939275Scripts/c71939275.lua1
Ghostrick Renovation61818176Scripts/c61818176.lua1
Hecahands Tartaros57809669Scripts/c57809669.lua1
Enneacraft - Asta.PIXEA28454232Scripts/c28454232.lua1
Odd-Eyes Revolution Dragon16306932Scripts/c16306932.lua1
Resurgam Xyz49082032Scripts/c49082032.lua1
Tohushaddoll Grysta95072744Scripts/c95072744.lua1
PSY-Framelord Omega74586817Scripts/c74586817.lua2
Teleport Fusion36494597Scripts/c36494597.lua1
Graydle Split75361204Scripts/c75361204.lua1
Enneacraft - Archa.TAIL81237046Scripts/c81237046.lua1
D/D/D/D Dimensional King Arc Crisis71398055Scripts/c71398055.lua1
...and 5075 more

Script Examples ​

Salamandra with Chain (62091148) ​

Source: Scripts/c62091148.lua

lua
		and Duel.IsExistingTarget(s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
	Duel.SelectTarget(tp,s.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
	Duel.SetOperationInfo(0,CATEGORY_EQUIP,e:GetHandler(),1,0,0)
end

Pendulum Evolution (55795155) ​

Source: Scripts/c55795155.lua

lua
	Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
	Duel.SelectTarget(tp,c55795155.atkfilter,tp,LOCATION_MZONE,0,1,1,nil)
end
function c55795155.atkop(e,tp,eg,ep,ev,re,r,rp)

Surprise Fusion (35167375) ​

Source: Scripts/c35167375.lua

lua
	if chk==0 then return Duel.IsExistingTarget(s.rafilter,tp,LOCATION_MZONE,0,1,nil) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP)
	local tc=Duel.SelectTarget(tp,s.rafilter,tp,LOCATION_MZONE,0,1,1,nil):GetFirst()
	local race,att
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RACE)