Effect.SetOperation
Signature
Effect.SetOperation(Effect e, nil|function op_func) -> voidDescription
Sets e's operation callback. Passing nil clears the operation. For activated effects, this callback resolves after the Chain reaches this Link, so it should re-check targets, locations, relation, and other state that may have changed since activation.
How To Use It
The operation callback performs the effect when the Chain resolves.
For targeted cards, retrieve the target and re-check that it is still related to the resolving effect before applying the action:
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
endPassing nil to SetOperation clears the operation. That is occasionally useful for effects whose category or target data is enough and no resolution callback is needed.
Related Functions
Parameters
eEffect- Effect whose operation callback is replaced or cleared.op_funcnil|function- Operation callback, or nil to clear it.
Source
D:\Programs\GitHub\ygopro-core\libeffect.cpp:629
Guided Examples
Learn how to use this function in context:
- Beginner Script Ladder
- Effects That Apply Continuously
- Cost, Target, And Operation Lifecycle
- Counter Traps
- Conditions, Costs, Activation Procedures, and Resolution
- Creation, Building, and Registration of an Effect Object
More guided lessons (2)
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 12825 indexed script(s).
- Search this function in the Script Explorer with
Effect.SetOperation.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.lua
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:SetCountLimit(1,id)
e1:SetTarget(s.ptg)
e1:SetOperation(s.pop)
c:RegisterEffect(e1)
--special summonArtmage Non-Finito (74631897)
Source: Scripts/c74631897.lua
e0:SetCode(EVENT_SPSUMMON_SUCCESS)
e0:SetCondition(s.condition)
e0:SetOperation(s.regop)
c:RegisterEffect(e0)
--spsummon condition