Generate a YGOPro Lua script for the following Yu-Gi-Oh card effect:
2 Level 4 monsters You can detach 1 material from this card; if you have more cards in your Extra Deck than your opponent's, apply these effects in sequence, depending on the difference. ● 1+: This card gains 1000 ATK until the end of your opponent's turn. ● 5+: Neither player can target this card with card effects until the end of your opponent's turn. ● 10+: Banish 1 card your opponent controls. ● 15+: Make your opponent's LP 3000. You can only use this effect of "Pendransaction" once per turn.
--ペンドラザクション
--Pendransaction
--Scripted by Eerie Code
local s,id=GetID()
function s.initial_effect(c)
	--Xyz Summon
	Xyz.AddProcedure(c,nil,4,2)
	c:EnableReviveLimit()
	--Apply effect
	local e1=Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_ATKCHANGE+CATEGORY_REMOVE)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1,id)
	e1:SetCost(Cost.DetachFromSelf(1))
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_EXTRA,0)-Duel.GetFieldGroupCount(tp,0,LOCATION_EXTRA)>0 end
end
function s.operation(e,tp,eg,ep,ev,re,r,rp)
	local c=e:GetHandler()
	local val=Duel.GetFieldGroupCount(tp,LOCATION_EXTRA,0)-Duel.GetFieldGroupCount(tp,0,LOCATION_EXTRA)
	--Increase ATK
	if val>=1 and c:IsRelateToEffect(e) and c:IsFaceup() then
		local e1=Effect.CreateEffect(c)
		e1:SetType(EFFECT_TYPE_SINGLE)
		e1:SetCode(EFFECT_UPDATE_ATTACK)
		e1:SetReset(RESETS_STANDARD_DISABLE_PHASE_END,2)
		e1:SetValue(1000)
		c:RegisterEffect(e1)
	end
	--Cannot be targeted by effects
	if val>=5 and c:IsRelateToEffect(e) and c:IsFaceup() then
		Duel.BreakEffect()
		local e2=Effect.CreateEffect(c)
		e2:SetType(EFFECT_TYPE_SINGLE)
		e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
		e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
		e2:SetRange(LOCATION_MZONE)
		e2:SetReset(RESETS_STANDARD_DISABLE_PHASE_END,2)
		e2:SetValue(1)
		c:RegisterEffect(e2)
	end
	--Banish 1 card the opponent controls
	if val>=10 then
		Duel.BreakEffect()
		Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
		local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0,LOCATION_ONFIELD,1,1,nil)
		if #g>0 then Duel.Remove(g,POS_FACEUP,REASON_EFFECT) end
	end
	--Change opponent's LP to 3000
	if val>=15 then
		Duel.BreakEffect()
		Duel.SetLP(1-tp,3000)
	end
end