Skip to content

Effect.SetTarget ​

Signature ​

lua
Effect.SetTarget(Effect e, function targ_func) -> void

Description ​

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.

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

Use Duel.SelectTarget for cards that are official targets. Use Duel.SetOperationInfo so chained cards can see what the effect is expected to do.

Parameters ​

  • e Effect - Effect whose target callback is replaced.
  • targ_func function - Callback function stored on e.

Source ​

  • D:\Programs\GitHub\ygopro-core\libeffect.cpp:626

Guided Examples ​

Learn how to use this function in context:

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.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua2
Astrograph Sorcerer, the Starfrost Magician48171151Scripts/c48171151.lua3
Artmage Non-Finito74631897Scripts/c74631897.lua3
Pendulum Evolution55795155Scripts/c55795155.lua3
Levia-Dragoon - Daedalus78579058Scripts/c78579058.lua3
Lady's Dragonmaid48658295Scripts/c48658295.lua3
Azure Ocean Dragon Lord - Neo-Daedalus Rage41570943Scripts/c41570943.lua3
Eternal Favorite87532344Scripts/c87532344.lua2
Surprise Fusion35167375Scripts/c35167375.lua2
Astrograph Sorcerer76794549Scripts/c76794549.lua3
Spellbook of the Grand Circle11911336Scripts/c11911336.lua2
Ultra Polymerization76647978Scripts/c76647978.lua2
Goyo Emperor59255742Scripts/c59255742.lua5
Accel Synchro Stardust Dragon30983281Scripts/c30983281.lua2
Melffy Playtime Surprise58036097Scripts/c58036097.lua3
Ashtraja Susanoo17020474Scripts/c17020474.lua2
Deftero Enneacraft - "alazoneIA"92171126Scripts/c92171126.lua5
Destiny HERO - Destro-Dogma25158975Scripts/c25158975.lua2
Yomagna the Fire Phantom17350692Scripts/c17350692.lua3
Fiendsmith's Sequence49867899Scripts/c49867899.lua2
D/D/D Alfred the Divine Sage King11852093Scripts/c11852093.lua2
El Shaddoll Apkallone50907446Scripts/c50907446.lua2
Mementotlan Fusion66518509Scripts/c66518509.lua2
Meteoroa Drytron24166324Scripts/c24166324.lua2
...and 12408 more

Script Examples ​

Salamandra with Chain (62091148) ​

Source: Scripts/c62091148.lua

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

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

lua
	e3:SetRange(LOCATION_EXTRA)
	e3:SetCondition(s.spcon)
	e3:SetTarget(s.sptg)
	e3:SetOperation(s.spop)
	c:RegisterEffect(e3)