name: Googly-Eyes
card_text: 2 Level 8 Machine-Type monsters
  Once per turn: You can detach 1 Xyz Material from this card; it gains 1000 ATK, until the end of your opponent's next turn. If this card is destroyed while it has Xyz Material: You can banish 1 "Super Defense Robot" monster from your Graveyard; Special Summon this card from your Graveyard, then, you can attach 1 "Super Defense Robot" monster from your Graveyard to this card as an Xyz Material.
external_ids: local SETCARD_ID_0 = 0x85 --Super
  
lua: local SETCARD_ID_0 = 0x85 --Super
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_MACHINE), 8, 2)
  	c:EnableReviveLimit()
  	--attack up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.spcon)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(1000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END, 2)
  		c:RegisterEffect(e1)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_DESTROY) and e:GetHandler():GetPreviousOverlayCountOnField() > 0
  end
  function s.rfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.rfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.rfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsRelateToEffect(e) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.mfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsCanOverlay()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.mfilter), tp, LOCATION_GRAVE, 0, nil)
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  			local mg = g:Select(tp, 1, 1, nil)
  			Duel.Overlay(c, mg)
  		end
  	end
  end
  
  
source_text: Googly-Eyes
  2 Level 8 Machine-Type monsters
  Once per turn: You can detach 1 Xyz Material from this card; it gains 1000 ATK, until the end of your opponent's next turn. If this card is destroyed while it has Xyz Material: You can banish 1 "Super Defense Robot" monster from your Graveyard; Special Summon this card from your Graveyard, then, you can attach 1 "Super Defense Robot" monster from your Graveyard to this card as an Xyz Material.
target_text: -- Googly-Eyes
  local SETCARD_ID_0 = 0x85 --Super
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsRace, RACE_MACHINE), 8, 2)
  	c:EnableReviveLimit()
  	--attack up
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_ATKCHANGE)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetCondition(s.spcon)
  	e2:SetCost(s.spcost)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(1000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END, 2)
  		c:RegisterEffect(e1)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_DESTROY) and e:GetHandler():GetPreviousOverlayCountOnField() > 0
  end
  function s.rfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.rfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.rfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsRelateToEffect(e) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.mfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsCanOverlay()
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) > 0 then
  		local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.mfilter), tp, LOCATION_GRAVE, 0, nil)
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 2)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  			local mg = g:Select(tp, 1, 1, nil)
  			Duel.Overlay(c, mg)
  		end
  	end
  end
  
  