name: Overlay
card_text: You can banish this card from your Graveyard; take 1 Xyz Material from a monster your opponent controls and attach it to an Xyz Monster you control as Xyz Material.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_GRAVE)
  	e1:SetCost(aux.bfgcost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetOverlayCount(tp, 0, 1) ~= 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetOverlayGroup(tp, 0, 1)
  	local g2 = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	if g1:GetCount() == 0 or g2:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  	local mg = g1:Select(tp, 1, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local tc = g2:Select(tp, 1, 1, nil):GetFirst()
  	local oc = mg:GetFirst():GetOverlayTarget()
  	Duel.Overlay(tc, mg)
  	Duel.RaiseSingleEvent(oc, EVENT_DETACH_MATERIAL, e, 0, 0, 0, 0)
  	Duel.RaiseEvent(oc, EVENT_DETACH_MATERIAL, e, 0, 0, 0, 0)
  end
  
  
source_text: Overlay
  You can banish this card from your Graveyard; take 1 Xyz Material from a monster your opponent controls and attach it to an Xyz Monster you control as Xyz Material.
target_text: -- Overlay
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_GRAVE)
  	e1:SetCost(aux.bfgcost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetOverlayCount(tp, 0, 1) ~= 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g1 = Duel.GetOverlayGroup(tp, 0, 1)
  	local g2 = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, 0, nil)
  	if g1:GetCount() == 0 or g2:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  	local mg = g1:Select(tp, 1, 1, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local tc = g2:Select(tp, 1, 1, nil):GetFirst()
  	local oc = mg:GetFirst():GetOverlayTarget()
  	Duel.Overlay(tc, mg)
  	Duel.RaiseSingleEvent(oc, EVENT_DETACH_MATERIAL, e, 0, 0, 0, 0)
  	Duel.RaiseEvent(oc, EVENT_DETACH_MATERIAL, e, 0, 0, 0, 0)
  end
  
  