name: Outrigger
card_text: Your opponent cannot target Machine Xyz Monsters you control with card effects. Once per turn: You can target 1 "Infinitrack" Xyz Monster you control; Special Summon from your Extra Deck, 1 Machine monster that is 2 Ranks higher than that target, by using that target as material, also you cannot Special Summon monsters for the rest of this turn, except EARTH Machine monsters (even if this card leaves the field). (This is treated as an Xyz Summon. Transfer its materials to the Summoned monster.)
external_ids: local SETCARD_ID_0 = 0x127 --Infinitrack
  
lua: local SETCARD_ID_0 = 0x127 --Infinitrack
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Cannot Become Target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.immtg)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--Rank Up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  end
  function s.immtg(e, c)
  	return c:IsRace(RACE_MACHINE) and c:IsType(TYPE_XYZ) and c:IsFaceup()
  end
  function s.tgfilter(c, e, tp)
  	return c:IsFaceup()
  		and c:IsType(TYPE_XYZ)
  		and c:IsSetCard(SETCARD_ID_0)
  		and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL)
  		and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c:GetRank() + 2, c)
  end
  function s.spfilter(c, e, tp, rank, mc)
  	return c:IsRace(RACE_MACHINE)
  		and c:IsType(TYPE_XYZ)
  		and c:IsRank(rank)
  		and mc:IsCanBeXyzMaterial(c, tp)
  		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.tgfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsControler(tp) and tc:IsFaceup() and aux.MustMaterialCheck(tc, tp, EFFECT_MUST_BE_XMATERIAL) and not tc:IsImmuneToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, tc:GetRank() + 2, tc)
  		local sc = g:GetFirst()
  		if sc then
  			local mg = tc:GetOverlayGroup()
  			if mg:GetCount() > 0 then
  				Duel.Overlay(sc, mg)
  			end
  			sc:SetMaterial(Group.FromCards(tc))
  			Duel.Overlay(sc, Group.FromCards(tc))
  			Duel.SpecialSummon(sc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  			sc:CompleteProcedure()
  		end
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not (c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_EARTH))
  end
  
  
source_text: Outrigger
  Your opponent cannot target Machine Xyz Monsters you control with card effects. Once per turn: You can target 1 "Infinitrack" Xyz Monster you control; Special Summon from your Extra Deck, 1 Machine monster that is 2 Ranks higher than that target, by using that target as material, also you cannot Special Summon monsters for the rest of this turn, except EARTH Machine monsters (even if this card leaves the field). (This is treated as an Xyz Summon. Transfer its materials to the Summoned monster.)
target_text: -- Outrigger
  local SETCARD_ID_0 = 0x127 --Infinitrack
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--Cannot Become Target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.immtg)
  	e2:SetValue(aux.tgoval)
  	c:RegisterEffect(e2)
  	--Rank Up
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  end
  function s.immtg(e, c)
  	return c:IsRace(RACE_MACHINE) and c:IsType(TYPE_XYZ) and c:IsFaceup()
  end
  function s.tgfilter(c, e, tp)
  	return c:IsFaceup()
  		and c:IsType(TYPE_XYZ)
  		and c:IsSetCard(SETCARD_ID_0)
  		and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL)
  		and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c:GetRank() + 2, c)
  end
  function s.spfilter(c, e, tp, rank, mc)
  	return c:IsRace(RACE_MACHINE)
  		and c:IsType(TYPE_XYZ)
  		and c:IsRank(rank)
  		and mc:IsCanBeXyzMaterial(c, tp)
  		and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.tgfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tgfilter, tp, LOCATION_MZONE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.tgfilter, tp, LOCATION_MZONE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsControler(tp) and tc:IsFaceup() and aux.MustMaterialCheck(tc, tp, EFFECT_MUST_BE_XMATERIAL) and not tc:IsImmuneToEffect(e) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, tc:GetRank() + 2, tc)
  		local sc = g:GetFirst()
  		if sc then
  			local mg = tc:GetOverlayGroup()
  			if mg:GetCount() > 0 then
  				Duel.Overlay(sc, mg)
  			end
  			sc:SetMaterial(Group.FromCards(tc))
  			Duel.Overlay(sc, Group.FromCards(tc))
  			Duel.SpecialSummon(sc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  			sc:CompleteProcedure()
  		end
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.splimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not (c:IsRace(RACE_MACHINE) and c:IsAttribute(ATTRIBUTE_EARTH))
  end
  
  