name: Zefraniu,
card_text: Pendulum Scale = 7
  [ Pendulum Effect ]
  You cannot Pendulum Summon monsters, except "Yang Zing" and "Zefra" monsters. This effect cannot be negated.
  ----------------------------------------
  [ Monster Effect ]
  When this card is Pendulum Summoned, or when this card is destroyed by battle or card effect while in your Monster Zone: You can add 1 "Yang Zing" or "Zefra" Spell/Trap from your Deck to your hand. You can only use this effect of "Zefraniu, Secret of the Yang Zing" once per turn.
external_ids: local SETCARD_ID_0 = 0x9e --Yang
  
lua: local SETCARD_ID_0 = 0x9e --Yang
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--splimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_PZONE)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_CAN_FORBIDDEN)
  	e2:SetTargetRange(1, 0)
  	e2:SetTarget(s.splimit)
  	c:RegisterEffect(e2)
  	--search
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.condition1)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EVENT_DESTROYED)
  	e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e4:SetCondition(s.condition2)
  	c:RegisterEffect(e4)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp)
  	if c:IsSetCard(SETCARD_ID_0, 0xc4) then
  		return false
  	end
  	return bit.band(sumtype, SUMMON_TYPE_PENDULUM) == SUMMON_TYPE_PENDULUM
  end
  function s.condition1(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_PENDULUM)
  end
  function s.condition2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousControler(tp)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0, 0xc4) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.target(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.operation(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 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Zefraniu,
  Pendulum Scale = 7
  [ Pendulum Effect ]
  You cannot Pendulum Summon monsters, except "Yang Zing" and "Zefra" monsters. This effect cannot be negated.
  ----------------------------------------
  [ Monster Effect ]
  When this card is Pendulum Summoned, or when this card is destroyed by battle or card effect while in your Monster Zone: You can add 1 "Yang Zing" or "Zefra" Spell/Trap from your Deck to your hand. You can only use this effect of "Zefraniu, Secret of the Yang Zing" once per turn.
target_text: -- Zefraniu,
  local SETCARD_ID_0 = 0x9e --Yang
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--pendulum summon
  	aux.EnablePendulumAttribute(c)
  	--splimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_PZONE)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_CAN_FORBIDDEN)
  	e2:SetTargetRange(1, 0)
  	e2:SetTarget(s.splimit)
  	c:RegisterEffect(e2)
  	--search
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.condition1)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EVENT_DESTROYED)
  	e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e4:SetCondition(s.condition2)
  	c:RegisterEffect(e4)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp)
  	if c:IsSetCard(SETCARD_ID_0, 0xc4) then
  		return false
  	end
  	return bit.band(sumtype, SUMMON_TYPE_PENDULUM) == SUMMON_TYPE_PENDULUM
  end
  function s.condition1(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_PENDULUM)
  end
  function s.condition2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousControler(tp)
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_0, 0xc4) and c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToHand()
  end
  function s.target(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.operation(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 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  