name: Lyrilusc
card_text: If you control a Winged Beast monster: You can Special Summon both this card and 1 Level 1 Winged Beast monster from your hand. You can only use this effect of "Lyrilusc - Sapphire Swallow" once per turn. A WIND Xyz Monster that was Summoned using this card on the field as material gains this effect.
  ● If it is Xyz Summoned: You can target 1 "Lyrilusc" monster in your GY; attach it to this card as material.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xf7 --Lyrilusc
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xf7 --Lyrilusc
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--effect gain
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e2:SetCondition(s.efcon)
  	e2:SetOperation(s.efop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_WINDBEAST)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_WINDBEAST) and c:IsLevel(1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 1
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  			and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, c, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 or Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or not c:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, c, e, tp)
  	if g:GetCount() > 0 then
  		g:AddCard(c)
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.efcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return r == REASON_XYZ and c:GetReasonCard():IsAttribute(ATTRIBUTE_WIND)
  end
  function s.efop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetCondition(s.xyzcon)
  	e1:SetTarget(s.xyztg)
  	e1:SetOperation(s.xyzop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  function s.xyzcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.xyzfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsCanOverlay()
  end
  function s.xyztg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.xyzfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.xyzfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local g = Duel.SelectTarget(tp, s.xyzfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.xyzop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsCanOverlay() then
  		Duel.Overlay(c, Group.FromCards(tc))
  	end
  end
  
  
source_text: Lyrilusc
  If you control a Winged Beast monster: You can Special Summon both this card and 1 Level 1 Winged Beast monster from your hand. You can only use this effect of "Lyrilusc - Sapphire Swallow" once per turn. A WIND Xyz Monster that was Summoned using this card on the field as material gains this effect.
  ● If it is Xyz Summoned: You can target 1 "Lyrilusc" monster in your GY; attach it to this card as material.
target_text: -- Lyrilusc
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xf7 --Lyrilusc
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--effect gain
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e2:SetCondition(s.efcon)
  	e2:SetOperation(s.efop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_WINDBEAST)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsRace(RACE_WINDBEAST) and c:IsLevel(1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 1
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  			and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, c, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) < 2 or Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		return
  	end
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or not c:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, c, e, tp)
  	if g:GetCount() > 0 then
  		g:AddCard(c)
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.efcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return r == REASON_XYZ and c:GetReasonCard():IsAttribute(ATTRIBUTE_WIND)
  end
  function s.efop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetCondition(s.xyzcon)
  	e1:SetTarget(s.xyztg)
  	e1:SetOperation(s.xyzop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  function s.xyzcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.xyzfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsCanOverlay()
  end
  function s.xyztg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.xyzfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.xyzfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local g = Duel.SelectTarget(tp, s.xyzfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.xyzop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsCanOverlay() then
  		Duel.Overlay(c, Group.FromCards(tc))
  	end
  end
  
  