name: Crystal
card_text: When this card is Special Summoned: You can Special Summon as many "Crystal Beast" Monster Cards as possible from your Spell & Trap Zones. If this face-up card is destroyed in a Monster Zone, you can place it face-up in your Spell & Trap Zone as a Continuous Spell, instead of sending it to the GY.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x1034 --Crystal
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x1034 --Crystal
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--send replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_TO_GRAVE_REDIRECT_CB)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCondition(s.repcon)
  	e1:SetOperation(s.repop)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.repcon(e)
  	local c = e:GetHandler()
  	return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_DESTROY)
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCode(EFFECT_CHANGE_TYPE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TURN_SET)
  	e1:SetValue(TYPE_SPELL + TYPE_CONTINUOUS)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, sp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, sp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_SZONE, 0, 1, nil, e, tp) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ct = 1
  	end
  	local gct = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_SZONE, 0, nil, e, tp)
  	if ct > gct then
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, gct, tp, LOCATION_SZONE)
  	else
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, ct, tp, LOCATION_SZONE)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ct <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ct = 1
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_SZONE, 0, nil, e, tp)
  	local gc = g:GetCount()
  	if gc == 0 then
  		return
  	end
  	if gc <= ct then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, ct, ct, nil)
  		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Crystal
  When this card is Special Summoned: You can Special Summon as many "Crystal Beast" Monster Cards as possible from your Spell & Trap Zones. If this face-up card is destroyed in a Monster Zone, you can place it face-up in your Spell & Trap Zone as a Continuous Spell, instead of sending it to the GY.
target_text: -- Crystal
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0x1034 --Crystal
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--send replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_TO_GRAVE_REDIRECT_CB)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCondition(s.repcon)
  	e1:SetOperation(s.repop)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.repcon(e)
  	local c = e:GetHandler()
  	return c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsReason(REASON_DESTROY)
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCode(EFFECT_CHANGE_TYPE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TURN_SET)
  	e1:SetValue(TYPE_SPELL + TYPE_CONTINUOUS)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, sp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, sp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_SZONE, 0, 1, nil, e, tp) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ct = 1
  	end
  	local gct = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_SZONE, 0, nil, e, tp)
  	if ct > gct then
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, gct, tp, LOCATION_SZONE)
  	else
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, ct, tp, LOCATION_SZONE)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ct = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ct <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ct = 1
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_SZONE, 0, nil, e, tp)
  	local gc = g:GetCount()
  	if gc == 0 then
  		return
  	end
  	if gc <= ct then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, ct, ct, nil)
  		Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  