name: Number
card_text: 2 Level 3 monsters
  Once per turn, if this card has material: You can target 1 "Number" Xyz Monster in your GY, except "Number 71: Rebarian Shark"; Special Summon it, and if you do, attach 1 material from this card to it. If this card is sent to the GY: You can place 1 "Rank-Up-Magic" Spell from your Deck on top of your Deck.
external_ids: local SETCARD_ID_0 = 0x95 --Rank-Up-Magic
  local SETCARD_ID_1 = 0x48 --Number
  
lua: local SETCARD_ID_0 = 0x95 --Rank-Up-Magic
  local SETCARD_ID_1 = 0x48 --Number
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, nil, 3, 2)
  	--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_MZONE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--to deck top
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetTarget(s.tdtg)
  	e2:SetOperation(s.tdop)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 71
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetOverlayCount() > 0
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_XYZ) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) > 0 and c:IsRelateToEffect(e) and c:GetOverlayCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  		local mg = c:GetOverlayGroup():Select(tp, 1, 1, nil)
  		local oc = mg:GetFirst():GetOverlayTarget()
  		Duel.Overlay(tc, mg)
  		Duel.RaiseSingleEvent(oc, EVENT_DETACH_MATERIAL, e, 0, 0, 0, 0)
  	end
  end
  function s.tdfilter(c)
  	return c:IsType(TYPE_SPELL) and c:IsSetCard(SETCARD_ID_1)
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tdfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 1
  	end
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 3))
  	local g = Duel.SelectMatchingCard(tp, s.tdfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.ShuffleDeck(tp)
  		Duel.MoveSequence(tc, SEQ_DECKTOP)
  		Duel.ConfirmDecktop(tp, 1)
  	end
  end
  
  
source_text: Number
  2 Level 3 monsters
  Once per turn, if this card has material: You can target 1 "Number" Xyz Monster in your GY, except "Number 71: Rebarian Shark"; Special Summon it, and if you do, attach 1 material from this card to it. If this card is sent to the GY: You can place 1 "Rank-Up-Magic" Spell from your Deck on top of your Deck.
target_text: -- Number
  local SETCARD_ID_0 = 0x95 --Rank-Up-Magic
  local SETCARD_ID_1 = 0x48 --Number
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, nil, 3, 2)
  	--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_MZONE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--to deck top
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DELAY)
  	e2:SetTarget(s.tdtg)
  	e2:SetOperation(s.tdop)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 71
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetOverlayCount() > 0
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_XYZ) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) > 0 and c:IsRelateToEffect(e) and c:GetOverlayCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  		local mg = c:GetOverlayGroup():Select(tp, 1, 1, nil)
  		local oc = mg:GetFirst():GetOverlayTarget()
  		Duel.Overlay(tc, mg)
  		Duel.RaiseSingleEvent(oc, EVENT_DETACH_MATERIAL, e, 0, 0, 0, 0)
  	end
  end
  function s.tdfilter(c)
  	return c:IsType(TYPE_SPELL) and c:IsSetCard(SETCARD_ID_1)
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tdfilter, tp, LOCATION_DECK, 0, 1, nil) and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 1
  	end
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 3))
  	local g = Duel.SelectMatchingCard(tp, s.tdfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.ShuffleDeck(tp)
  		Duel.MoveSequence(tc, SEQ_DECKTOP)
  		Duel.ConfirmDecktop(tp, 1)
  	end
  end
  
  