name: Wightmare
card_text: This card's name becomes "Skull Servant" while in the GY. You can discard this card, then activate 1 of the following effects.
  ● Target 1 of your banished "Skull Servant" or "Wightmare"; return it to the GY.
  ● Target 1 of your banished "The Lady in Wight" or "King of the Skull Servants"; Special Summon it.
external_ids: local CARD_ID_0 = 36021814 --King of the Skull Servants
  local CARD_ID_1 = 32274490 --Skull Servant
  local CARD_ID_2 = 40991587 --The Lady in Wight
  
lua: local CARD_ID_0 = 36021814 --King of the Skull Servants
  local CARD_ID_1 = 32274490 --Skull Servant
  local CARD_ID_2 = 40991587 --The Lady in Wight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--change code
  	aux.EnableChangeCode(c, CARD_ID_1, LOCATION_GRAVE)
  	--to grave
  	local e2 = Effect.CreateEffect(c)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_1, id)
  end
  function s.spfilter(c, e, tp)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0, CARD_ID_2) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		if e:GetLabel() == 0 then
  			return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.tgfilter(chkc)
  		else
  			return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  		end
  	end
  	local b1 = Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_REMOVED, 0, 1, nil)
  	local b2 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_REMOVED, 0, 1, nil, e, tp)
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_TOGRAVE)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_REMOVED, 0, 1, 1, nil)
  		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_REMOVED, 0, 1, 1, nil, e, tp)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	end
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if e:GetLabel() == 0 then
  		if tc:IsRelateToEffect(e) then
  			Duel.SendtoGrave(tc, REASON_EFFECT + REASON_RETURN)
  		end
  	else
  		if tc:IsRelateToEffect(e) then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Wightmare
  This card's name becomes "Skull Servant" while in the GY. You can discard this card, then activate 1 of the following effects.
  ● Target 1 of your banished "Skull Servant" or "Wightmare"; return it to the GY.
  ● Target 1 of your banished "The Lady in Wight" or "King of the Skull Servants"; Special Summon it.
target_text: -- Wightmare
  local CARD_ID_0 = 36021814 --King of the Skull Servants
  local CARD_ID_1 = 32274490 --Skull Servant
  local CARD_ID_2 = 40991587 --The Lady in Wight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--change code
  	aux.EnableChangeCode(c, CARD_ID_1, LOCATION_GRAVE)
  	--to grave
  	local e2 = Effect.CreateEffect(c)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_1, id)
  end
  function s.spfilter(c, e, tp)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0, CARD_ID_2) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		if e:GetLabel() == 0 then
  			return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.tgfilter(chkc)
  		else
  			return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  		end
  	end
  	local b1 = Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_REMOVED, 0, 1, nil)
  	local b2 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_REMOVED, 0, 1, nil, e, tp)
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_TOGRAVE)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local g = Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_REMOVED, 0, 1, 1, nil)
  		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, g, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_REMOVED, 0, 1, 1, nil, e, tp)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	end
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if e:GetLabel() == 0 then
  		if tc:IsRelateToEffect(e) then
  			Duel.SendtoGrave(tc, REASON_EFFECT + REASON_RETURN)
  		end
  	else
  		if tc:IsRelateToEffect(e) then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  