name: Mecha
card_text: Cannot be used as a Synchro Material Monster, except for the Synchro Summon of a Machine monster. The other Synchro Material Monster(s) are "Mecha Phantom Beast" monsters in your hand or on your field. While you control a Token, this card cannot be destroyed by battle or card effects. If only your opponent controls a monster: You can banish this card from your GY; Special Summon 1 "Mecha Phantom Beast Token" (Machine/WIND/Level 3/ATK 0/DEF 0).
external_ids: local CARD_ID_0 = 67489920 --Mecha Phantom Beast Token
  local CARD_ID_1 = 31533705 --Mecha Phantom Beast Token
  local SETCARD_ID_0 = 0x101b --Mecha
  
lua: local CARD_ID_0 = 67489920 --Mecha Phantom Beast Token
  local CARD_ID_1 = 31533705 --Mecha Phantom Beast Token
  local SETCARD_ID_0 = 0x101b --Mecha
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetCondition(aux.tkfcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e2)
  	--token
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCondition(s.spcon)
  	e3:SetCost(aux.bfgcost)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--synlimit
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
  	e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e5:SetValue(s.synlimit)
  	c:RegisterEffect(e5)
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_TUNER_MATERIAL_LIMIT)
  	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e6:SetTarget(s.synlimit2)
  	e6:SetValue(LOCATION_MZONE + LOCATION_HAND)
  	c:RegisterEffect(e6)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0 and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	if Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND) then
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummon(token, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.synlimit(e, c)
  	if not c then
  		return false
  	end
  	return not c:IsRace(RACE_MACHINE)
  end
  function s.synlimit2(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  
source_text: Mecha
  Cannot be used as a Synchro Material Monster, except for the Synchro Summon of a Machine monster. The other Synchro Material Monster(s) are "Mecha Phantom Beast" monsters in your hand or on your field. While you control a Token, this card cannot be destroyed by battle or card effects. If only your opponent controls a monster: You can banish this card from your GY; Special Summon 1 "Mecha Phantom Beast Token" (Machine/WIND/Level 3/ATK 0/DEF 0).
target_text: -- Mecha
  local CARD_ID_0 = 67489920 --Mecha Phantom Beast Token
  local CARD_ID_1 = 31533705 --Mecha Phantom Beast Token
  local SETCARD_ID_0 = 0x101b --Mecha
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetCondition(aux.tkfcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e2)
  	--token
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_GRAVE)
  	e3:SetCondition(s.spcon)
  	e3:SetCost(aux.bfgcost)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--synlimit
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
  	e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e5:SetValue(s.synlimit)
  	c:RegisterEffect(e5)
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_TUNER_MATERIAL_LIMIT)
  	e6:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e6:SetTarget(s.synlimit2)
  	e6:SetValue(LOCATION_MZONE + LOCATION_HAND)
  	c:RegisterEffect(e6)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == 0 and Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE) > 0
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	if Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 3, RACE_MACHINE, ATTRIBUTE_WIND) then
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummon(token, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.synlimit(e, c)
  	if not c then
  		return false
  	end
  	return not c:IsRace(RACE_MACHINE)
  end
  function s.synlimit2(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  
  