name: Wings
card_text: During the Main Phase: Add 1 "Supreme King Dragon" or "Supreme King Gate" Pendulum Monster from your Deck to your hand, or if you control "Supreme King Z-ARC", you can Special Summon it instead. You can only activate 1 "Wings of Light" per turn.
external_ids: local CARD_ID_0 = 13331639 --Supreme King Z-ARC
  local SETCARD_ID_0 = 0x10f8 --Supreme
  
lua: local CARD_ID_0 = 13331639 --Supreme King Z-ARC
  local SETCARD_ID_0 = 0x10f8 --Supreme
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.filter(c, e, tp, check)
  	return c:IsSetCard(SETCARD_ID_0, 0x20f8) and c:IsType(TYPE_PENDULUM) and (c:IsAbleToHand() or check and c:IsCanBeSpecialSummoned(e, 0, tp, false, false))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local check = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, e, tp, check)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local check = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, check)
  	if g:GetCount() <= 0 then
  		return
  	end
  	local tc = g:GetFirst()
  	local b = check and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	if tc:IsAbleToHand() and (not b or Duel.SelectOption(tp, 1190, 1152) == 0) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	else
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Wings
  During the Main Phase: Add 1 "Supreme King Dragon" or "Supreme King Gate" Pendulum Monster from your Deck to your hand, or if you control "Supreme King Z-ARC", you can Special Summon it instead. You can only activate 1 "Wings of Light" per turn.
target_text: -- Wings
  local CARD_ID_0 = 13331639 --Supreme King Z-ARC
  local SETCARD_ID_0 = 0x10f8 --Supreme
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.filter(c, e, tp, check)
  	return c:IsSetCard(SETCARD_ID_0, 0x20f8) and c:IsType(TYPE_PENDULUM) and (c:IsAbleToHand() or check and c:IsCanBeSpecialSummoned(e, 0, tp, false, false))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local check = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, e, tp, check)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local check = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, check)
  	if g:GetCount() <= 0 then
  		return
  	end
  	local tc = g:GetFirst()
  	local b = check and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	if tc:IsAbleToHand() and (not b or Duel.SelectOption(tp, 1190, 1152) == 0) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	else
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  