Skip to content

Effect.SetCost ​

Signature ​

lua
Effect.SetCost(Effect e, function cost_func) -> void

Description ​

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

Do not perform irreversible actions during the chk==0 check. The engine may call that branch just to test activation legality.

Parameters ​

  • e Effect - Effect whose cost callback is replaced.
  • cost_func function - 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:

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.
CardIDScriptDetected Calls
Salamandra with Chain62091148Scripts/c62091148.lua2
Levia-Dragoon - Daedalus78579058Scripts/c78579058.lua1
Azure Ocean Dragon Lord - Neo-Daedalus Rage41570943Scripts/c41570943.lua1
Eternal Favorite87532344Scripts/c87532344.lua1
Surprise Fusion35167375Scripts/c35167375.lua1
Astrograph Sorcerer76794549Scripts/c76794549.lua1
Spellbook of the Grand Circle11911336Scripts/c11911336.lua1
Ultra Polymerization76647978Scripts/c76647978.lua2
Goyo Emperor59255742Scripts/c59255742.lua1
Accel Synchro Stardust Dragon30983281Scripts/c30983281.lua1
Melffy Playtime Surprise58036097Scripts/c58036097.lua1
Ashtraja Susanoo17020474Scripts/c17020474.lua1
Deftero Enneacraft - "alazoneIA"92171126Scripts/c92171126.lua3
Mementotlan Fusion66518509Scripts/c66518509.lua1
Meteoroa Drytron24166324Scripts/c24166324.lua2
Ehther the Heavenly Monarch96570609Scripts/c96570609.lua1
Lubellion the Searing Dragon70534340Scripts/c70534340.lua1
Ghostrick Renovation61818176Scripts/c61818176.lua1
Ursarctic Polari27693363Scripts/c27693363.lua1
Prank-Kids Weather Washer44509529Scripts/c44509529.lua1
Enneacraft - Asta.PIXEA28454232Scripts/c28454232.lua2
Odd-Eyes Revolution Dragon16306932Scripts/c16306932.lua2
Aiwass, Divine Spirit of the Law84288367Scripts/c84288367.lua1
Resurgam Xyz49082032Scripts/c49082032.lua1
...and 4785 more

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)