name: Procession
card_text: Face-down Defense Position monsters in this card's column cannot change their battle positions, also neither player can activate the Set cards in the Spell & Trap Zones in this card's column. You can only use each of the following effects of "Procession of the Tea Jar" once per turn. During your Main Phase: You can move this card to an unused adjacent Main Monster Zone. If this card in the Monster Zone moves to another Monster Zone: Change all other monsters in this card's current column to face-down Defense Position.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot change pos or activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_CHANGE_POSITION)
  	e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_CANNOT_TRIGGER)
  	e2:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e2:SetTarget(s.target2)
  	c:RegisterEffect(e2)
  	--move
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.seqcon)
  	e3:SetOperation(s.seqop)
  	c:RegisterEffect(e3)
  	--move
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_POSITION)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_MOVE)
  	e4:SetCountLimit(1, id + 1)
  	e4:SetCondition(s.poscon)
  	e4:SetTarget(s.postg)
  	e4:SetOperation(s.posop)
  	c:RegisterEffect(e4)
  end
  function s.target(e, c)
  	return c:IsPosition(POS_FACEDOWN_DEFENSE) and e:GetHandler():GetColumnGroup():IsContains(c)
  end
  function s.target2(e, c)
  	return c:IsPosition(POS_FACEDOWN) and e:GetHandler():GetColumnGroup():IsContains(c)
  end
  function s.seqcon(e, tp, eg, ep, ev, re, r, rp)
  	local seq = e:GetHandler():GetSequence()
  	if seq > 4 then
  		return false
  	end
  	return (seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1)) or (seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1))
  end
  function s.seqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or c:IsControler(1 - tp) then
  		return
  	end
  	local seq = c:GetSequence()
  	if seq > 4 then
  		return
  	end
  	if (seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1)) or (seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1)) then
  		local flag = 0
  		if seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1) then
  			flag = bit.replace(flag, 0x1, seq - 1)
  		end
  		if seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1) then
  			flag = bit.replace(flag, 0x1, seq + 1)
  		end
  		flag = bit.bxor(flag, 0xff)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOZONE)
  		local s = Duel.SelectDisableField(tp, 1, LOCATION_MZONE, 0, flag)
  		local nseq = 0
  		if s == 1 then
  			nseq = 0
  		elseif s == 2 then
  			nseq = 1
  		elseif s == 4 then
  			nseq = 2
  		elseif s == 8 then
  			nseq = 3
  		else
  			nseq = 4
  		end
  		Duel.MoveSequence(c, nseq)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsLocation(LOCATION_MZONE) and (c:GetPreviousSequence() ~= c:GetSequence() or c:GetPreviousControler() ~= tp)
  end
  function s.posfilter(c, e)
  	return c:IsCanTurnSet() and e:GetHandler():GetColumnGroup():IsContains(c)
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(s.posfilter, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler(), e)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.posfilter, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler(), e)
  	Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
  end
  
  
source_text: Procession
  Face-down Defense Position monsters in this card's column cannot change their battle positions, also neither player can activate the Set cards in the Spell & Trap Zones in this card's column. You can only use each of the following effects of "Procession of the Tea Jar" once per turn. During your Main Phase: You can move this card to an unused adjacent Main Monster Zone. If this card in the Monster Zone moves to another Monster Zone: Change all other monsters in this card's current column to face-down Defense Position.
target_text: -- Procession
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot change pos or activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_CHANGE_POSITION)
  	e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e1:SetTarget(s.target)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_CANNOT_TRIGGER)
  	e2:SetTargetRange(LOCATION_SZONE, LOCATION_SZONE)
  	e2:SetTarget(s.target2)
  	c:RegisterEffect(e2)
  	--move
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.seqcon)
  	e3:SetOperation(s.seqop)
  	c:RegisterEffect(e3)
  	--move
  	local e4 = Effect.CreateEffect(c)
  	e4:SetCategory(CATEGORY_POSITION)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e4:SetCode(EVENT_MOVE)
  	e4:SetCountLimit(1, id + 1)
  	e4:SetCondition(s.poscon)
  	e4:SetTarget(s.postg)
  	e4:SetOperation(s.posop)
  	c:RegisterEffect(e4)
  end
  function s.target(e, c)
  	return c:IsPosition(POS_FACEDOWN_DEFENSE) and e:GetHandler():GetColumnGroup():IsContains(c)
  end
  function s.target2(e, c)
  	return c:IsPosition(POS_FACEDOWN) and e:GetHandler():GetColumnGroup():IsContains(c)
  end
  function s.seqcon(e, tp, eg, ep, ev, re, r, rp)
  	local seq = e:GetHandler():GetSequence()
  	if seq > 4 then
  		return false
  	end
  	return (seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1)) or (seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1))
  end
  function s.seqop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or c:IsControler(1 - tp) then
  		return
  	end
  	local seq = c:GetSequence()
  	if seq > 4 then
  		return
  	end
  	if (seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1)) or (seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1)) then
  		local flag = 0
  		if seq > 0 and Duel.CheckLocation(tp, LOCATION_MZONE, seq - 1) then
  			flag = bit.replace(flag, 0x1, seq - 1)
  		end
  		if seq < 4 and Duel.CheckLocation(tp, LOCATION_MZONE, seq + 1) then
  			flag = bit.replace(flag, 0x1, seq + 1)
  		end
  		flag = bit.bxor(flag, 0xff)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOZONE)
  		local s = Duel.SelectDisableField(tp, 1, LOCATION_MZONE, 0, flag)
  		local nseq = 0
  		if s == 1 then
  			nseq = 0
  		elseif s == 2 then
  			nseq = 1
  		elseif s == 4 then
  			nseq = 2
  		elseif s == 8 then
  			nseq = 3
  		else
  			nseq = 4
  		end
  		Duel.MoveSequence(c, nseq)
  	end
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsPreviousLocation(LOCATION_MZONE) and c:IsLocation(LOCATION_MZONE) and (c:GetPreviousSequence() ~= c:GetSequence() or c:GetPreviousControler() ~= tp)
  end
  function s.posfilter(c, e)
  	return c:IsCanTurnSet() and e:GetHandler():GetColumnGroup():IsContains(c)
  end
  function s.postg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return true
  	end
  	local g = Duel.GetMatchingGroup(s.posfilter, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler(), e)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.posfilter, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler(), e)
  	Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
  end
  
  