name: Number
card_text: 2 Level 4 monsters
  Once per turn: You can detach 1 Xyz Material from this card; change this card's DEF to 0, and if you do, change its ATK to 3000. These changes last until the end of this turn. If this card attacks, it is changed to Defense Position at the end of the Battle Phase. If this card is attacked, change it to Attack Position at the end of the Damage Step if it has no Xyz Materials. You can only control 1 "Number 52: Diamond Crab King".
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 0, id)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--atk/def
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.adcost)
  	e1:SetOperation(s.adop)
  	c:RegisterEffect(e1)
  	--pos
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.poscon1)
  	e2:SetOperation(s.posop1)
  	c:RegisterEffect(e2)
  	--pos
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetCondition(s.poscon2)
  	e3:SetOperation(s.posop2)
  	c:RegisterEffect(e3)
  end
  aux.xyz_number[id] = 52
  function s.adcost(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.adop(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_SET_ATTACK_FINAL)
  		e1:SetValue(3000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_SET_DEFENSE_FINAL)
  		e2:SetValue(0)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e2)
  	end
  end
  function s.poscon1(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop1(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsAttackPos() then
  		Duel.ChangePosition(e:GetHandler(), POS_FACEUP_DEFENSE)
  	end
  end
  function s.poscon2(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler() == Duel.GetAttackTarget() and e:GetHandler():GetOverlayCount() == 0
  end
  function s.posop2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToBattle() and c:IsDefensePos() then
  		Duel.ChangePosition(c, POS_FACEUP_ATTACK)
  	end
  end
  
  
source_text: Number
  2 Level 4 monsters
  Once per turn: You can detach 1 Xyz Material from this card; change this card's DEF to 0, and if you do, change its ATK to 3000. These changes last until the end of this turn. If this card attacks, it is changed to Defense Position at the end of the Battle Phase. If this card is attacked, change it to Attack Position at the end of the Damage Step if it has no Xyz Materials. You can only control 1 "Number 52: Diamond Crab King".
target_text: -- Number
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 0, id)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--atk/def
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.adcost)
  	e1:SetOperation(s.adop)
  	c:RegisterEffect(e1)
  	--pos
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.poscon1)
  	e2:SetOperation(s.posop1)
  	c:RegisterEffect(e2)
  	--pos
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_DAMAGE_STEP_END)
  	e3:SetCondition(s.poscon2)
  	e3:SetOperation(s.posop2)
  	c:RegisterEffect(e3)
  end
  aux.xyz_number[id] = 52
  function s.adcost(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.adop(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_SET_ATTACK_FINAL)
  		e1:SetValue(3000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_SET_DEFENSE_FINAL)
  		e2:SetValue(0)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e2)
  	end
  end
  function s.poscon1(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop1(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsAttackPos() then
  		Duel.ChangePosition(e:GetHandler(), POS_FACEUP_DEFENSE)
  	end
  end
  function s.poscon2(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler() == Duel.GetAttackTarget() and e:GetHandler():GetOverlayCount() == 0
  end
  function s.posop2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToBattle() and c:IsDefensePos() then
  		Duel.ChangePosition(c, POS_FACEUP_ATTACK)
  	end
  end
  
  