Jump to content

Custom script help


DM999

Recommended Posts

I wanted to make a custom quick-play spell card that says "pay half your LP and tribute 1 "Cyber Dragon" you control; Special Summon 1 "Cyber Twin Dragon" from your extra deck, ignoring it's summoning conditions", but I can't activate it. Can someone help me fix the script? Here's what it currently looks like:

--

function s.initial_effect(c)
    --activate
    local e1=Effect.CreateEffect(c)
    e1:SetDescription(aux.Stringid(sid,0))
    e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
    e1:SetType(EFFECT_TYPE_ACTIVATE)
    e1:SetCode(EVENT_FREE_CHAIN)

    e1:SetCountLimit(1,sid)
    e1:SetCost(s.cost)
    e1:SetTarget(s.target)
    e1:SetOperation(s.operation)
    c:RegisterEffect(e1)

function s.costfilter(c)
    return c:IsCode(70095154)
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
    if chk==0 then return Duel.CheckLPCost(tp,math.floor(Duel.GetLP(tp)/2)) and Duel.CheckReleaseGroup(tp,s.costfilter,1,nil) end
    Duel.PayLPCost(tp,math.floor(Duel.GetLP(tp)/2))
    local sg=Duel.SelectReleaseGroup(tp,s.costfilter,1,1,nil)
    Duel.Release(sg,REASON_COST)
end
function s.filter(c,e,tp)
    return c:IsCode(74157028) and c:IsCanBeSpecialSummoned(e,0,tp,true,true)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
    if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
        and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end
    Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
    if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
    Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
    local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp)
    if g:GetCount()>0 then
        Duel.SpecialSummon(g,0,tp,tp,true,true,POS_FACEUP)
    end
end

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...