Hey guys, I have a bit of trouble with this effect:
"If a Token is used for this card's Synchro Summon: Draw 1 card for each Token that was used for this card's Synchro Summon."
--mat check
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetCode(EFFECT_MATERIAL_CHECK)
e0:SetValue(c54105540.matcheck)
c:RegisterEffect(e0)
--draw (Token)
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_DRAW)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c54105540.condition2)
e2:SetTarget(c54105540.target2)
e2:SetOperation(c54105540.operation2)
c:RegisterEffect(e2)
end
function c54105540.matcheck(e,c)
local ct=c:GetMaterial():Filter(Card.IsType,nil,TYPE_TOKEN)
e:SetLabel(ct)
end
function c54105540.condition2(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
return c:GetSummonType()==SUMMON_TYPE_SYNCHRO and c:GetMaterial():IsExists(c54105540.mfilter2,1,nil)
end
function c54105540.mfilter2(c)
return c:IsType(TYPE_TOKEN)
end
function c54105540.target2(e,tp,eg,ep,ev,re,r,rp,chk)
local ct=e:GetLabelObject():GetLabel()
if chk==0 then return Duel.IsPlayerCanDraw(tp,ct) and ct>0 end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(ct)
Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,ct)
end
function c54105540.operation2(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Draw(p,d,REASON_EFFECT)
end
I get the error message "60: attempt to index a nil value" (line 60 is highlighted)
Also I am not sure if I need the "matcheck" function. I've never done such an effect before.
Thanks for help 🙂
Edited by user
2016-10-31T14:23:39Z
|
Reason: Not specified