Effect.SetCost
Signature
lua
Effect.SetCost(Effect e, function cost_func) -> voidDescription
Sets e's cost callback. For activated effects, the callback checks whether the cost can be paid and then pays it. Cost callbacks should only test legality when chk is 0; irreversible payment belongs in the nonzero chk branch.
How To Use It
Cost callbacks usually have two phases. When chk==0, only answer whether the cost can be paid. When chk is not 0, actually pay the cost.
lua
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckLPCost(tp,1000) end
Duel.PayLPCost(tp,1000)
endDo not perform irreversible actions during the chk==0 check. The engine may call that branch just to test activation legality.
Related Functions
Parameters
eEffect- Effect whose cost callback is replaced.cost_funcfunction- Callback usually shaped as cost_func(e,tp,eg,ep,ev,re,r,rp,chk).
Source
D:\Programs\GitHub\ygopro-core\libeffect.cpp:627
Guided Examples
Learn how to use this function in context:
- Cost, Target, And Operation Lifecycle
- Counter Traps
- Conditions, Costs, Activation Procedures, and Resolution
Used By
Generated from the local Scripts/ folder and cards.cdb.
- Detected in 4809 indexed script(s).
- Search this function in the Script Explorer with
Effect.SetCost.
Script Examples
Salamandra with Chain (62091148)
Source: Scripts/c62091148.lua
lua
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCondition(aux.dscon)
e1:SetCost(s.cost)
e1:SetTarget(s.target)
e1:SetOperation(s.operation)Levia-Dragoon - Daedalus (78579058)
Source: Scripts/c78579058.lua
lua
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END)
e2:SetCondition(s.drcon)
e2:SetCost(s.drcost)
e2:SetTarget(s.drtg)
e2:SetOperation(s.drop)Azure Ocean Dragon Lord - Neo-Daedalus Rage (41570943)
Source: Scripts/c41570943.lua
lua
e2:SetCountLimit(1)
e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e2:SetCost(s.tgcost)
e2:SetTarget(s.tgtg)
e2:SetOperation(s.tgop)