name: Vaylantz
card_text: Add 1 "Vaylantz" Field Spell from your Deck to your hand, then you can apply the following effect.
  ● Destroy 1 Pendulum Monster Card you control, and if you do, add 1 "Senet Switch" from your Deck to your hand.
  If this card is in your GY, except the turn it was sent there: You can banish this card; place 1 face-up "Vaylantz" Pendulum Monster from your Extra Deck in your Pendulum Zone. You can only use each effect of "Vaylantz Wars - The Place of Beginning" once per turn.
external_ids: local CARD_ID_0 = 63394872 --Senet Switch
  local SETCARD_ID_0 = 0x17d --Vaylantz
  
lua: local CARD_ID_0 = 63394872 --Senet Switch
  local SETCARD_ID_0 = 0x17d --Vaylantz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--pzone set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(aux.exccon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.pstg)
  	e2:SetOperation(s.psop)
  	c:RegisterEffect(e2)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_FIELD) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:GetOriginalType() & TYPE_PENDULUM ~= 0
  end
  function s.sfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 and Duel.SendtoHand(g, nil, REASON_EFFECT) > 0 and g:GetFirst():IsLocation(LOCATION_HAND) then
  		Duel.ConfirmCards(1 - tp, g)
  		local dg = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_ONFIELD, 0, nil)
  		local sg = Duel.GetMatchingGroup(s.sfilter, tp, LOCATION_DECK, 0, nil)
  		if dg:GetCount() > 0 and sg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  			local dc = dg:Select(tp, 1, 1, nil)
  			Duel.HintSelection(dc)
  			if Duel.Destroy(dc, REASON_EFFECT) > 0 then
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  				local sc = sg:Select(tp, 1, 1, nil)
  				Duel.SendtoHand(sc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, sc)
  			end
  		end
  	end
  end
  function s.psfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM) and not c:IsForbidden()
  end
  function s.pstg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)) and Duel.IsExistingMatchingCard(s.psfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  end
  function s.psop(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.CheckLocation(tp, LOCATION_PZONE, 0) and not Duel.CheckLocation(tp, LOCATION_PZONE, 1) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOFIELD)
  	local g = Duel.SelectMatchingCard(tp, s.psfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.MoveToField(g:GetFirst(), tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  	end
  end
  
  
source_text: Vaylantz
  Add 1 "Vaylantz" Field Spell from your Deck to your hand, then you can apply the following effect.
  ● Destroy 1 Pendulum Monster Card you control, and if you do, add 1 "Senet Switch" from your Deck to your hand.
  If this card is in your GY, except the turn it was sent there: You can banish this card; place 1 face-up "Vaylantz" Pendulum Monster from your Extra Deck in your Pendulum Zone. You can only use each effect of "Vaylantz Wars - The Place of Beginning" once per turn.
target_text: -- Vaylantz
  local CARD_ID_0 = 63394872 --Senet Switch
  local SETCARD_ID_0 = 0x17d --Vaylantz
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--pzone set
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(aux.exccon)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.pstg)
  	e2:SetOperation(s.psop)
  	c:RegisterEffect(e2)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_FIELD) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:GetOriginalType() & TYPE_PENDULUM ~= 0
  end
  function s.sfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 and Duel.SendtoHand(g, nil, REASON_EFFECT) > 0 and g:GetFirst():IsLocation(LOCATION_HAND) then
  		Duel.ConfirmCards(1 - tp, g)
  		local dg = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_ONFIELD, 0, nil)
  		local sg = Duel.GetMatchingGroup(s.sfilter, tp, LOCATION_DECK, 0, nil)
  		if dg:GetCount() > 0 and sg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  			local dc = dg:Select(tp, 1, 1, nil)
  			Duel.HintSelection(dc)
  			if Duel.Destroy(dc, REASON_EFFECT) > 0 then
  				Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  				local sc = sg:Select(tp, 1, 1, nil)
  				Duel.SendtoHand(sc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, sc)
  			end
  		end
  	end
  end
  function s.psfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_PENDULUM) and not c:IsForbidden()
  end
  function s.pstg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)) and Duel.IsExistingMatchingCard(s.psfilter, tp, LOCATION_EXTRA, 0, 1, nil)
  	end
  end
  function s.psop(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.CheckLocation(tp, LOCATION_PZONE, 0) and not Duel.CheckLocation(tp, LOCATION_PZONE, 1) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOFIELD)
  	local g = Duel.SelectMatchingCard(tp, s.psfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.MoveToField(g:GetFirst(), tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  	end
  end
  
  