Mecha
If this card is Special Summoned: Special Summon 2 "Mecha Phantom Beast Tokens" (Machine/WIND/Level 3/ATK 0/DEF 0). You must control another "Mecha Phantom Beast" monster to activate and to resolve this effect. This card's Level is increased by the total Levels of all "Mecha Phantom Beast Tokens" you control. While you control a Token, this card cannot be destroyed by battle or card effects. Once per turn: You can Tribute 2 Tokens, then target 1 card your opponent controls; destroy that target, and if you do, banish it.
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 94973029 --Mecha Phantom Beast Token
local CARD_ID_2 = 31533705 --Mecha Phantom Beast Token
local SETCARD_ID_0 = 0x101b --Mecha

local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 94973029 --Mecha Phantom Beast Token
local CARD_ID_2 = 31533705 --Mecha Phantom Beast Token
local SETCARD_ID_0 = 0x101b --Mecha
local s, id, o = GetID()
function s.initial_effect(c)
	--level
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCode(EFFECT_UPDATE_LEVEL)
	e1:SetValue(s.lvval)
	c:RegisterEffect(e1)
	--indes
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
	e2:SetCondition(aux.tkfcon)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	c:RegisterEffect(e3)
	--token
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
	e4:SetCondition(s.spcon)
	e4:SetTarget(s.sptg)
	e4:SetOperation(s.spop)
	c:RegisterEffect(e4)
	--destroy
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetCategory(CATEGORY_DESTROY)
	e5:SetType(EFFECT_TYPE_IGNITION)
	e5:SetRange(LOCATION_MZONE)
	e5:SetCountLimit(1)
	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e5:SetCost(s.descost)
	e5:SetTarget(s.destg)
	e5:SetOperation(s.desop)
	c:RegisterEffect(e5)
end
function s.lvval(e, c)
	local tp = c:GetControler()
	return Duel.GetMatchingGroup(Card.IsCode, tp, LOCATION_MZONE, 0, nil, CARD_ID_2):GetSum(Card.GetLevel)
end
function s.cfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 2, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		return
	end
	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 1 then
		return
	end
	if Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND) then
		local token = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
		token = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
		Duel.SpecialSummonComplete()
	end
end
function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.CheckReleaseGroup(tp, Card.IsType, 2, nil, TYPE_TOKEN)
	end
	local g = Duel.SelectReleaseGroup(tp, Card.IsType, 2, 2, nil, TYPE_TOKEN)
	Duel.Release(g, REASON_COST)
end
function s.desfilter(c)
	return c:IsAbleToRemove()
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsControler(1 - tp) and chkc:IsOnField() and s.desfilter(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.desfilter, tp, 0, LOCATION_ONFIELD, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, s.desfilter, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		Duel.Destroy(tc, REASON_EFFECT, LOCATION_REMOVED)
	end
end


Mecha
If this card is Special Summoned: Special Summon 2 "Mecha Phantom Beast Tokens" (Machine/WIND/Level 3/ATK 0/DEF 0). You must control another "Mecha Phantom Beast" monster to activate and to resolve this effect. This card's Level is increased by the total Levels of all "Mecha Phantom Beast Tokens" you control. While you control a Token, this card cannot be destroyed by battle or card effects. Once per turn: You can Tribute 2 Tokens, then target 1 card your opponent controls; destroy that target, and if you do, banish it.
-- Mecha
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 94973029 --Mecha Phantom Beast Token
local CARD_ID_2 = 31533705 --Mecha Phantom Beast Token
local SETCARD_ID_0 = 0x101b --Mecha
local s, id, o = GetID()
function s.initial_effect(c)
	--level
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCode(EFFECT_UPDATE_LEVEL)
	e1:SetValue(s.lvval)
	c:RegisterEffect(e1)
	--indes
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_SINGLE)
	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
	e2:SetCondition(aux.tkfcon)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	c:RegisterEffect(e3)
	--token
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 0))
	e4:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
	e4:SetCode(EVENT_SPSUMMON_SUCCESS)
	e4:SetCondition(s.spcon)
	e4:SetTarget(s.sptg)
	e4:SetOperation(s.spop)
	c:RegisterEffect(e4)
	--destroy
	local e5 = Effect.CreateEffect(c)
	e5:SetDescription(aux.Stringid(id, 1))
	e5:SetCategory(CATEGORY_DESTROY)
	e5:SetType(EFFECT_TYPE_IGNITION)
	e5:SetRange(LOCATION_MZONE)
	e5:SetCountLimit(1)
	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e5:SetCost(s.descost)
	e5:SetTarget(s.destg)
	e5:SetOperation(s.desop)
	c:RegisterEffect(e5)
end
function s.lvval(e, c)
	local tp = c:GetControler()
	return Duel.GetMatchingGroup(Card.IsCode, tp, LOCATION_MZONE, 0, nil, CARD_ID_2):GetSum(Card.GetLevel)
end
function s.cfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, e:GetHandler())
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 2, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, 0, 0)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		return
	end
	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 1 then
		return
	end
	if Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND) then
		local token = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
		token = Duel.CreateToken(tp, id + 1)
		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
		Duel.SpecialSummonComplete()
	end
end
function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.CheckReleaseGroup(tp, Card.IsType, 2, nil, TYPE_TOKEN)
	end
	local g = Duel.SelectReleaseGroup(tp, Card.IsType, 2, 2, nil, TYPE_TOKEN)
	Duel.Release(g, REASON_COST)
end
function s.desfilter(c)
	return c:IsAbleToRemove()
end
function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
	if chkc then
		return chkc:IsControler(1 - tp) and chkc:IsOnField() and s.desfilter(chkc)
	end
	if chk == 0 then
		return Duel.IsExistingTarget(s.desfilter, tp, 0, LOCATION_ONFIELD, 1, nil)
	end
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
	local g = Duel.SelectTarget(tp, s.desfilter, tp, 0, LOCATION_ONFIELD, 1, 1, nil)
	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
end
function s.desop(e, tp, eg, ep, ev, re, r, rp)
	local tc = Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		Duel.Destroy(tc, REASON_EFFECT, LOCATION_REMOVED)
	end
end

