Generate a YGOPro Lua script for the following Yu-Gi-Oh card effect:
Apply these effects until the end of this turn. ● Rank 3 or lower Xyz Monsters gain 500 ATK and DEF. ● Rank 4 or higher Xyz Monsters cannot attack.
--プランクスケール
--Planckton
local s,id=GetID()
function s.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetCode(EFFECT_UPDATE_ATTACK)
	e1:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
	e1:SetValue(500)
	e1:SetTarget(s.filter1)
	e1:SetReset(RESET_PHASE|PHASE_END)
	Duel.RegisterEffect(e1,tp)
	local e2=e1:Clone()
	e2:SetCode(EFFECT_UPDATE_DEFENSE)
	Duel.RegisterEffect(e2,tp)
	local e3=Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_CANNOT_ATTACK)
	e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
	e3:SetReset(RESET_PHASE|PHASE_END)
	e3:SetTarget(s.filter2)
	Duel.RegisterEffect(e3,tp)
end
function s.filter1(e,c)
	return c:IsType(TYPE_XYZ) and c:IsRankBelow(3)
end
function s.filter2(e,c)
	return c:IsType(TYPE_XYZ) and c:IsRankAbove(4)
end