name: Toy
card_text: You can Set this card from your hand to your Spell & Trap Zone as a Spell. You can only use each of the following effects of "Toy Tank" once per turn. If this Set card in the Spell & Trap Zone is sent to the GY: You can Special Summon this card. You can Tribute this monster; Special Summon 1 Level 6 or lower monster from your hand, or, if you control "Toy Box", you can Special Summon 1 Level 6 or lower monster from your GY instead, except "Toy Tank".
external_ids: local CARD_ID_0 = 24878656 --Toy Box
  
lua: local CARD_ID_0 = 24878656 --Toy Box
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Set
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_MONSTER_SSET)
  	e1:SetValue(TYPE_SPELL)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--release & spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.spcost)
  	e3:SetTarget(s.sptg1)
  	e3:SetOperation(s.spop1)
  	c:RegisterEffect(e3)
  end
  s.set_as_spell = true
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_SZONE) and c:IsPreviousPosition(POS_FACEDOWN)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.spfilter(c, e, tp, check)
  	return c:IsLevelBelow(6) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (c:IsLocation(LOCATION_HAND) or (check and not c:IsCode(id)))
  end
  function s.checkfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.sptg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  		return Duel.GetMZoneCount(tp, e:GetHandler()) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp, check)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.spop1(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 check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp, check)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Toy
  You can Set this card from your hand to your Spell & Trap Zone as a Spell. You can only use each of the following effects of "Toy Tank" once per turn. If this Set card in the Spell & Trap Zone is sent to the GY: You can Special Summon this card. You can Tribute this monster; Special Summon 1 Level 6 or lower monster from your hand, or, if you control "Toy Box", you can Special Summon 1 Level 6 or lower monster from your GY instead, except "Toy Tank".
target_text: -- Toy
  local CARD_ID_0 = 24878656 --Toy Box
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Set
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_MONSTER_SSET)
  	e1:SetValue(TYPE_SPELL)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--release & spsummon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetCost(s.spcost)
  	e3:SetTarget(s.sptg1)
  	e3:SetOperation(s.spop1)
  	c:RegisterEffect(e3)
  end
  s.set_as_spell = true
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_SZONE) and c:IsPreviousPosition(POS_FACEDOWN)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable()
  	end
  	Duel.Release(e:GetHandler(), REASON_COST)
  end
  function s.spfilter(c, e, tp, check)
  	return c:IsLevelBelow(6) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (c:IsLocation(LOCATION_HAND) or (check and not c:IsCode(id)))
  end
  function s.checkfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.sptg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  		return Duel.GetMZoneCount(tp, e:GetHandler()) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, nil, e, tp, check)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.spop1(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 check = Duel.IsExistingMatchingCard(s.checkfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, nil, e, tp, check)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  