I'm trying to script two cards. They're work mostly fine, just one effect each that doesn't work.
The first is a Field Spell
Effect:
While this card is face-up on the field, face-up "Lord of the Red", "Knight of Dark Dragon", and "Black Skull Dragon Archfiend" are treated as "Red-Eyes" monsters while on the field or in the Graveyard. "Red-Eyes" Gemini monsters you control are treated as Effect monsters, and gain their effect(s). Face-up "Red-Eyes" cards you control cannot be targeted by your opponent's card effects. "Red-Eyes" monster you control gain 300 ATK x the number of "Red-Eyes" cards in your Graveyard until the end of your turn.
Once per turn you may activate one of the following effects:
(1) Target up to 2 of your banished "Red-Eyes" or Dragon-type monsters; return them to the Graveyard.
(2) Discard 1 card; you can Special Summon 1 "Red-Eyes" monster from your hand or graveyard.
Script:
--Domain of Red-Eyes
function c723949.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--ATK boost
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_UPDATE_ATTACK)
e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x3b))
e2:SetValue(c723949.val)
c:RegisterEffect(e2)
--cannot be target
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD)
e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e4:SetRange(LOCATION_SZONE)
e4:SetTargetRange(LOCATION_MZONE,0)
e4:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x3b))
e4:SetValue(aux.tgoval)
c:RegisterEffect(e4)
--Gemini
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD)
e5:SetRange(LOCATION_SZONE)
e5:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e5:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x3b,Card.IsType,TYPE_DUAL))
e5:SetCode(EFFECT_DUAL_STATUS)
c:RegisterEffect(e5)
--Return banished Red-Eyes
local e6=Effect.CreateEffect(c)
e6:SetDescription(aux.Stringid(723949,1))
e6:SetCategory(CATEGORY_TOGRAVE)
e6:SetType(EFFECT_TYPE_IGNITION)
e6:SetProperty(EFFECT_FLAG_CARD_TARGET)
e6:SetCountLimit(1,723949)
e6:SetCode(EVENT_FREE_CHAIN)
e6:SetRange(LOCATION_SZONE)
e6:SetTarget(c723949.target)
e6:SetOperation(c723949.activate)
c:RegisterEffect(e6)
--spsummon
local e7=Effect.CreateEffect(c)
e7:SetDescription(aux.Stringid(723949,0))
e7:SetCategory(CATEGORY_SPECIAL_SUMMON)
e7:SetType(EFFECT_TYPE_IGNITION)
e7:SetCountLimit(1)
e7:SetRange(LOCATION_SZONE)
e7:SetTarget(c723949.sptg)
e7:SetOperation(c723949.spop)
c:RegisterEffect(e7)
end
function c723949.val(e,c)
return Duel.GetMatchingGroupCount(Card.IsSetCard,e:GetHandlerPlayer(),LOCATION_GRAVE+LOCATION_MZONE+LOCATION_SZONE,0,nil,0x3b)*300
end
function c723949.filter(c)
return c:IsFaceup() and c:IsSetCard(0x3b) or c:IsRace(RACE_DRAGON)
end
function c723949.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_REMOVED) and c723949.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c723949.filter,tp,LOCATION_REMOVED,LOCATION_REMOVED,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(723949,0))
local g=Duel.SelectTarget(tp,c723949.filter,tp,LOCATION_REMOVED,LOCATION_REMOVED,1,3,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,g:GetCount(),0,0)
end
function c723949.activate(e,tp,eg,ep,ev,re,r,rp)
local tg=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local sg=tg:Filter(Card.IsRelateToEffect,nil,e)
if sg:GetCount()>0 then
Duel.SendtoGrave(sg,REASON_EFFECT+REASON_RETURN)
end
function c723949.filter2(c,e,tp)
return c:IsSetCard(0x3b) and c:GetCode()~=723949
and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c723949.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
and Duel.IsExistingMatchingCard(c723949.filter2,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE+LOCATION_HAND)
end
function c723949.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_SZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c723949.filter2,tp,LOCATION_GRAVE+LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end
end
Problem: It says at line 59 (the first bolded part; the second is the corresponding function) that Parameter 2 should be a 'Function'. The effect is basically copied from Red-Eyes Darkness Metal Dragon.
Also, I would like to add the underlined effect as well, but I don't know how to do that part (treating certain cards as part of a different archetype only while on field or in grave)
The second card is a Ritual Spell
Effect:
This card can be used to Ritual Summon "Lord of the Red" or "Knight of Dark Dragon" from your hand or graveyard. You must also tribute monsters from the field or hand whose total Level are equal to or higher than the Level of the Ritual Monster you are attempting to Ritual Summon. During your Main Phase, except the turn this card was sent to the Graveyard: You can banish this card from your Graveyard; Special Summon 1 "Red-Eyes" monster from your Graveyard, ignoring its Summoning conditions.
Script:
--Ritual of the Red-Eyes
function c76146317.initial_effect(c)
aux.AddRitualProcGreater(c,c76146317.ritual_filter)
--Revive
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetType(EFFECT_TYPE_IGNITION)
e2:SetRange(LOCATION_GRAVE)
e2:SetCondition(c76146317.thcon)
e2:SetCost(c76146317.thcost)
e2:SetTarget(c76146317.thtg)
e2:SetOperation(c76146317.thop)
c:RegisterEffect(e2)
end
function c76146317.ritual_filter(c)
local code=c:GetCode()
return code==19025379 or code==71408082
end
function c76146317.thcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():GetTurnID()~=Duel.GetTurnCount()
end
function c76146317.thcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST)
end
function c76146317.thfilter(e,tp,eg,ep,ev,re,r,rp,chk)
return c:IsSetCard(0x3b) and c:IsCanBeSpecialSummoned(e,tp,true,true)
end
function c76146317.thtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c76146317.thfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_GRAVE)
end
function c76146317.thop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c76146317.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
end
Problem: It says at line 29 'attempt to index global 'c' (a nil value)'
INOV 2016. Make Red-Eyes great again