Duel.SelectTarget
Signature
Duel.SelectTarget(int sel_player, [function|nil f], int player, int s, int o, int min, int max, [Card|Group|nil ex], ... any) -> GroupDescription
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.
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
endRelated Functions
Parameters
sel_playerint- Player who makes the selection.ffunction|niloptional - Filter called with each candidate card first, then any extra arguments after ex.playerint- Viewpoint player for s and o.sint- Locations on player's side to search.oint- Locations on the opponent's side to search.minint- Minimum number of cards to select.maxint- Maximum number of cards to select.exCard|Group|niloptional - 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:
- Beginner Script Ladder
- Categories, Properties, And Hint Timing
- Client UI And Prompt Behavior
- Common Script Errors And Debugging
- Filters, Card Objects, and Group Objects
- Write Your First Custom Card
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.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.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)
endPendulum Evolution (55795155)
Source: Scripts/c55795155.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
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)