name: Outer
card_text: 2 Level 4 monsters
  When this card is Xyz Summoned: You can discard any number of cards; increase this card's Rank by the number of discarded cards. Once per turn, while this card has Xyz Material: You can target 1 monster in your GY; detach all materials from this card, and if you do, attach that target to this card as material. When a monster is attached by this effect, this card's Type and Attribute become the same as that monster's original Type and Attribute.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--rankup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.rkcon)
  	e1:SetCost(s.rkcost)
  	e1:SetOperation(s.rkop)
  	c:RegisterEffect(e1)
  	--attach
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.condition)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.rkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.rkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	local ct = Duel.DiscardHand(tp, Card.IsDiscardable, 1, 60, REASON_COST + REASON_DISCARD)
  	e:SetLabel(ct)
  end
  function s.rkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_UPDATE_RANK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e2:SetValue(e:GetLabel())
  		c:RegisterEffect(e2)
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsType(TYPE_XYZ) and e:GetHandler():GetOverlayCount() > 0
  end
  function s.matfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsCanOverlay()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.matfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.matfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local g = Duel.SelectTarget(tp, s.matfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsCanOverlay() then
  		local og = c:GetOverlayGroup()
  		if og:GetCount() == 0 then
  			return
  		end
  		Duel.SendtoGrave(og, REASON_EFFECT)
  		Duel.Overlay(c, Group.FromCards(tc))
  		if c:IsFacedown() then
  			return
  		end
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
  		e1:SetValue(tc:GetOriginalAttribute())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CHANGE_RACE)
  		e2:SetValue(tc:GetOriginalRace())
  		c:RegisterEffect(e2)
  	end
  end
  
  
source_text: Outer
  2 Level 4 monsters
  When this card is Xyz Summoned: You can discard any number of cards; increase this card's Rank by the number of discarded cards. Once per turn, while this card has Xyz Material: You can target 1 monster in your GY; detach all materials from this card, and if you do, attach that target to this card as material. When a monster is attached by this effect, this card's Type and Attribute become the same as that monster's original Type and Attribute.
target_text: -- Outer
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--rankup
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.rkcon)
  	e1:SetCost(s.rkcost)
  	e1:SetOperation(s.rkop)
  	c:RegisterEffect(e1)
  	--attach
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.condition)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.rkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.rkcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	local ct = Duel.DiscardHand(tp, Card.IsDiscardable, 1, 60, REASON_COST + REASON_DISCARD)
  	e:SetLabel(ct)
  end
  function s.rkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_UPDATE_RANK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e2:SetValue(e:GetLabel())
  		c:RegisterEffect(e2)
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsType(TYPE_XYZ) and e:GetHandler():GetOverlayCount() > 0
  end
  function s.matfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsCanOverlay()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.matfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.matfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	local g = Duel.SelectTarget(tp, s.matfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, g, 1, 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsCanOverlay() then
  		local og = c:GetOverlayGroup()
  		if og:GetCount() == 0 then
  			return
  		end
  		Duel.SendtoGrave(og, REASON_EFFECT)
  		Duel.Overlay(c, Group.FromCards(tc))
  		if c:IsFacedown() then
  			return
  		end
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_ATTRIBUTE)
  		e1:SetValue(tc:GetOriginalAttribute())
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CHANGE_RACE)
  		e2:SetValue(tc:GetOriginalRace())
  		c:RegisterEffect(e2)
  	end
  end
  
  