name: Goblin
card_text: 2+ Level 3 monsters
  While 3 or more Xyz Materials are attached to monsters on the field, "Goblin" monsters you control can attack directly. Once per turn, if a monster(s) is Normal or Special Summoned, while this card is in the Monster Zone (except during the Damage Step): You can target 1 of those monsters; detach 1 material from a monster on either field, and if you do, change the targeted monster's battle position. Once per turn, when an opponent's monster declares an attack: You can detach 1 material from a monster on either field, and if you do, negate that attack.
external_ids: local SETCARD_ID_0 = 0xac --Goblin
  
lua: local SETCARD_ID_0 = 0xac --Goblin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, nil, 3, 2, nil, nil, 14)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetCondition(s.dacon)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	c:RegisterEffect(e1)
  	--pos
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_POSITION)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e2:SetTarget(s.postg)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--negate attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.negcon)
  	e4:SetOperation(s.negop)
  	c:RegisterEffect(e4)
  end
  function s.dacon(e)
  	return Duel.GetOverlayCount(0, 1, 1) >= 3
  end
  function s.filter(c, e)
  	return c:IsCanChangePosition() and c:IsCanBeEffectTarget(e) and c:IsLocation(LOCATION_MZONE)
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.filter, 1, nil, e) and not eg:IsContains(e:GetHandler()) and Duel.CheckRemoveOverlayCard(tp, 1, 1, 1, REASON_EFFECT)
  	end
  	local tc = eg:FilterSelect(tp, s.filter, 1, 1, nil, e)
  	Duel.SetTargetCard(tc)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, tc, 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.RemoveOverlayCard(tp, 1, 1, 1, 1, REASON_EFFECT) ~= 0 then
  		Duel.ChangePosition(tc, POS_FACEUP_DEFENSE, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK)
  	end
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():GetControler() ~= tp and Duel.CheckRemoveOverlayCard(tp, 1, 1, 1, REASON_EFFECT)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.RemoveOverlayCard(tp, 1, 1, 1, 1, REASON_EFFECT) ~= 0 then
  		Duel.NegateAttack()
  	end
  end
  
  
source_text: Goblin
  2+ Level 3 monsters
  While 3 or more Xyz Materials are attached to monsters on the field, "Goblin" monsters you control can attack directly. Once per turn, if a monster(s) is Normal or Special Summoned, while this card is in the Monster Zone (except during the Damage Step): You can target 1 of those monsters; detach 1 material from a monster on either field, and if you do, change the targeted monster's battle position. Once per turn, when an opponent's monster declares an attack: You can detach 1 material from a monster on either field, and if you do, negate that attack.
target_text: -- Goblin
  local SETCARD_ID_0 = 0xac --Goblin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	c:EnableReviveLimit()
  	aux.AddXyzProcedure(c, nil, 3, 2, nil, nil, 14)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetCondition(s.dacon)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	c:RegisterEffect(e1)
  	--pos
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_POSITION)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, EFFECT_COUNT_CODE_SINGLE)
  	e2:SetTarget(s.postg)
  	e2:SetOperation(s.posop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--negate attack
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.negcon)
  	e4:SetOperation(s.negop)
  	c:RegisterEffect(e4)
  end
  function s.dacon(e)
  	return Duel.GetOverlayCount(0, 1, 1) >= 3
  end
  function s.filter(c, e)
  	return c:IsCanChangePosition() and c:IsCanBeEffectTarget(e) and c:IsLocation(LOCATION_MZONE)
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.filter, 1, nil, e) and not eg:IsContains(e:GetHandler()) and Duel.CheckRemoveOverlayCard(tp, 1, 1, 1, REASON_EFFECT)
  	end
  	local tc = eg:FilterSelect(tp, s.filter, 1, 1, nil, e)
  	Duel.SetTargetCard(tc)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, tc, 1, 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.RemoveOverlayCard(tp, 1, 1, 1, 1, REASON_EFFECT) ~= 0 then
  		Duel.ChangePosition(tc, POS_FACEUP_DEFENSE, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK, POS_FACEUP_ATTACK)
  	end
  end
  function s.negcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetAttacker():GetControler() ~= tp and Duel.CheckRemoveOverlayCard(tp, 1, 1, 1, REASON_EFFECT)
  end
  function s.negop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.RemoveOverlayCard(tp, 1, 1, 1, 1, REASON_EFFECT) ~= 0 then
  		Duel.NegateAttack()
  	end
  end
  
  