Effect.SetTarget
Signature
Effect.SetTarget(Effect e, function targ_func) -> voidDescription
Sets e's target callback. For activated effects, this callback performs activation legality checks and records target or operation information. Target callbacks normally use chk==0 only to answer legality, then use the real activation branch to select official targets with Duel.SelectTarget, record broad targets with Duel.SetTargetCard, or announce operation details with Duel.SetOperationInfo.
How To Use It
Target callbacks do two jobs for activated effects: answer activation legality during chk==0, then record targets and operation information when activation is accepted.
function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) end
if chk==0 then
return Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_ONFIELD,1,nil)
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_ONFIELD,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,nil,1,1-tp,LOCATION_ONFIELD)
endUse Duel.SelectTarget for cards that are official targets. Use Duel.SetOperationInfo so chained cards can see what the effect is expected to do.
Related Functions
Parameters
eEffect- Effect whose target callback is replaced.targ_funcfunction- Callback function stored on e.
Source
D:\Programs\GitHub\ygopro-core\libeffect.cpp:626
Guided Examples
Learn how to use this function in context:
- Beginner Script Ladder
- Effects That Apply Continuously
- Continuous Stat Modifiers
- Cost, Target, And Operation Lifecycle
- Counter Traps
- Conditions, Costs, Activation Procedures, and Resolution
More guided lessons (5)
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 12432 indexed script(s).
- Search this function in the Script Explorer with
Effect.SetTarget.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.lua
e1:SetCondition(aux.dscon)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.operation)
c:RegisterEffect(e1)Astrograph Sorcerer, the Starfrost Magician (48171151)
Source: Scripts/c48171151.lua
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1,id)
e1:SetTarget(s.ptg)
e1:SetOperation(s.pop)
c:RegisterEffect(e1)Artmage Non-Finito (74631897)
Source: Scripts/c74631897.lua
e3:SetRange(LOCATION_EXTRA)
e3:SetCondition(s.spcon)
e3:SetTarget(s.sptg)
e3:SetOperation(s.spop)
c:RegisterEffect(e3)