Jump to content

Im a noob, what am I doing wrong


Arimetal

Recommended Posts

I wanted to see if I could handle the task of programming cards. Decided to go for what I thought would be easy: A custom anime Earthbound I made earlier today that special effect allows you to conduct the bp twice. Idk what Im doing wrong cuz the only effect that works is the restriction of summoning other earthbounds.

 

I would appreciate someone looking over this and informing me wth I'm doing wrong. Below I have the lua script and the error message I get.

 

[spoiler=Code]function c58468202.initial_effect©
    local e0=Effect.CreateEffect©
    e0:SetType(EFFECT_TYPE_FIELD)
    e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
    e0:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
    e0:SetRange(LOCATION_MZONE)
    e0:SetTargetRange(1,0)
    e0:SetTarget(c58468202.sumlimit)
    c:RegisterEffect(e0)
    local e1=e0:Clone()
    e1:SetCode(EFFECT_CANNOT_SUMMON)
    c:RegisterEffect(e1)
    local e2=e0:Clone()
    e2:SetCode(EFFECT_CANNOT_FLIP_SUMMON)
    c:RegisterEffect(e2)
    --Can Attack Directly
    local e3=Effect.CreateEffect©
    e3:SetType(EFFECT_TYPE_SINGLE)
    e3:SetCode(EFFECT_DIRECT_ATTACK)
    e3:SetCondition(c58468202.havefieldcon)
    c:RegisterEffect(e3)
    --Unaffected by Spell and Trap Cards
    local e4=Effect.CreateEffect©
    e4:SetType(EFFECT_TYPE_SINGLE)
    e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
    e4:SetRange(LOCATION_MZONE)
    e4:SetCode(EFFECT_IMMUNE_EFFECT)
    e4:SetCondition(c58468202.havefieldcon)
    e4:SetValue(c58468202.unaffectedval)
    c:RegisterEffect(e4)
    --Cannot be Battle Target
    local e5=Effect.CreateEffect©
    e5:SetType(EFFECT_TYPE_SINGLE)
    e5:SetCode(EFFECT_IGNORE_BATTLE_TARGET)
    e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
    e5:SetRange(LOCATION_MZONE)
    e5:SetCondition(c58468202.havefieldcon)
    c:RegisterEffect(e5)
    --Conduct BP Twice
    local e1=Effect.CreateEffect©
    e6:SetDescription(aux.Stringid(58468202,0))
    e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
    e6:SetTarget(c58468202.target)
    e6:SetOperation(c58468202.operation)
    c:RegisterEffect(e6)
    local e7=Effect.CreateEffect©
    e7:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
    e7:SetRange(LOCATION_MZONE)
    e7:SetCountLimit(1)
    e7:SetCode(EVENT_PHASE+PHASE_END)
    e7:SetCondition(c58468202.nofieldcon)
    e7:SetOperation(c58468202.nofieldop)
    c:RegisterEffect(e7)
end
function c58468202.sumlimit(e,c,sump,sumtype,sumpos,targetp,se)
    return c:IsSetCard(0x21)
end
function c58468202.havefieldfilter©
    return c:IsFaceup() and c:IsType(TYPE_FIELD)
end
function c58468202.havefieldcon(e)
    return Duel.IsExistingMatchingCard(c58468202.havefieldfilter,0,LOCATION_SZONE,LOCATION_SZONE,1,e:GetHandler())
end
function c58468202.unaffectedval(e,te)
    return (te:IsActiveType(TYPE_SPELL) or te:IsActiveType(TYPE_TRAP)) and te:GetOwnerPlayer()~=e:GetHandlerPlayer()
end
function c58468202.operation(e,tp,eg,ep,ev,re,r,rp)
    local g=Duel.GetMatchingGroup(c58468202.filter,tp,0,LOCATION_ONFIELD,nil)
    if chk==0 then return true end
        local e1=Effect.CreateEffect(e:GetHandler())
        e1:SetType(EFFECT_TYPE_FIELD)
        e1:SetCode(EFFECT_BP_TWICE)
        e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
        e1:SetTargetRange(1,0)
        if Duel.GetTurnPlayer()==tp and (Duel.GetCurrentPhase()>=PHASE_BATTLE_START and Duel.GetCurrentPhase()<=PHASE_BATTLE) then
            e1:SetLabel(Duel.GetTurnCount())
            e1:SetCondition(c58468202.bpcon)
            e1:SetReset(RESET_PHASE+PHASE_BATTLE+RESET_SELF_TURN,2)
        else
            e1:SetReset(RESET_PHASE+PHASE_BATTLE+RESET_SELF_TURN,1)
        end
        Duel.RegisterEffect(e1,tp)
    end
function c58468202.nofieldcon(e)
    local f1=Duel.GetFieldCard(0,LOCATION_SZONE,5)
    local f2=Duel.GetFieldCard(1,LOCATION_SZONE,5)
    return (f1==nil or not f1:IsFaceup()) and (f2==nil or not f2:IsFaceup())
end
function c58468202.nofieldop(e,tp,eg,ep,ev,re,r,rp)
    Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end

 

 

[spoiler=Error Message]

[script Error]: [string "./script/c58468202.lua"] :21: Parameter 2 should be "Function".

 

 

Link to post
Share on other sites

Update: Coding is for f***ing nerds. Keep getting [script Error]: [string "./script/c58468202.lua"]:42: attempt to index a nil value (global 'e6')

 

Done so much HELL YEAH to line 42 over and over again but nothing.

 

I know its somethin I did wrong cuz thats where the double bp effect comes in. Pulled it off of Weather Report and switched some of the parts with Memory Crush King.

 

Updating op to current lua code.

Link to post
Share on other sites

Update: Coding is for f***ing nerds. Keep getting [script Error]: [string "./script/c58468202.lua"]:42: attempt to index a nil value (global 'e6')

 

Done so much HELL YEAH to line 42 over and over again but nothing.

 

I know its somethin I did wrong cuz thats where the double bp effect comes in. Pulled it off of Weather Report and switched some of the parts with Memory Crush King.

 

Updating op to current lua code.

Isn't yugioh also for nerds? ( ;

Link to post
Share on other sites

Archived

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

×
×
  • Create New...