name: Crystron
card_text: During your opponent's Main or Battle Phase (Quick Effect): You can Special Summon 1 non-Tuner monster from your hand, but its effects are negated (if any), and if you do, immediately after this effect resolves, Synchro Summon 1 Machine Synchro Monster using only that monster and this card. You can only use this effect of "Crystron Quan" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_MAIN_END + TIMING_BATTLE_START + TIMING_BATTLE_END)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.sccon)
  	e1:SetTarget(s.sctg)
  	e1:SetOperation(s.scop)
  	c:RegisterEffect(e1)
  end
  function s.sccon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return not e:GetHandler():IsStatus(STATUS_CHAINING) and Duel.GetTurnPlayer() ~= tp and (ph == PHASE_MAIN1 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE) or ph == PHASE_MAIN2)
  end
  function s.scfilter1(c, e, tp, mc)
  	local mg = Group.FromCards(c, mc)
  	return not c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.IsExistingMatchingCard(s.scfilter2, tp, LOCATION_EXTRA, 0, 1, nil, mg)
  end
  function s.scfilter2(c, mg)
  	return c:IsRace(RACE_MACHINE) and c:IsSynchroSummonable(nil, mg)
  end
  function s.sctg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummonCount(tp, 2)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingMatchingCard(s.scfilter1, tp, LOCATION_HAND, 0, 1, nil, e, tp, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.scop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local g = Duel.SelectMatchingCard(tp, s.scfilter1, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, c)
  	local tc = g:GetFirst()
  	if not tc or not Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	tc:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_DISABLE_EFFECT)
  	e2:SetValue(RESET_TURN_SET)
  	tc:RegisterEffect(e2)
  	Duel.SpecialSummonComplete()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.AdjustAll()
  	local mg = Group.FromCards(c, tc)
  	if mg:FilterCount(Card.IsLocation, nil, LOCATION_MZONE) < 2 then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.scfilter2, tp, LOCATION_EXTRA, 0, nil, mg)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SynchroSummon(tp, sg:GetFirst(), nil, mg)
  	end
  end
  
  
source_text: Crystron
  During your opponent's Main or Battle Phase (Quick Effect): You can Special Summon 1 non-Tuner monster from your hand, but its effects are negated (if any), and if you do, immediately after this effect resolves, Synchro Summon 1 Machine Synchro Monster using only that monster and this card. You can only use this effect of "Crystron Quan" once per turn.
target_text: -- Crystron
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_MAIN_END + TIMING_BATTLE_START + TIMING_BATTLE_END)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.sccon)
  	e1:SetTarget(s.sctg)
  	e1:SetOperation(s.scop)
  	c:RegisterEffect(e1)
  end
  function s.sccon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return not e:GetHandler():IsStatus(STATUS_CHAINING) and Duel.GetTurnPlayer() ~= tp and (ph == PHASE_MAIN1 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE) or ph == PHASE_MAIN2)
  end
  function s.scfilter1(c, e, tp, mc)
  	local mg = Group.FromCards(c, mc)
  	return not c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.IsExistingMatchingCard(s.scfilter2, tp, LOCATION_EXTRA, 0, 1, nil, mg)
  end
  function s.scfilter2(c, mg)
  	return c:IsRace(RACE_MACHINE) and c:IsSynchroSummonable(nil, mg)
  end
  function s.sctg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummonCount(tp, 2)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingMatchingCard(s.scfilter1, tp, LOCATION_HAND, 0, 1, nil, e, tp, e:GetHandler())
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.scop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local c = e:GetHandler()
  	local g = Duel.SelectMatchingCard(tp, s.scfilter1, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, c)
  	local tc = g:GetFirst()
  	if not tc or not Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	tc:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_DISABLE_EFFECT)
  	e2:SetValue(RESET_TURN_SET)
  	tc:RegisterEffect(e2)
  	Duel.SpecialSummonComplete()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.AdjustAll()
  	local mg = Group.FromCards(c, tc)
  	if mg:FilterCount(Card.IsLocation, nil, LOCATION_MZONE) < 2 then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.scfilter2, tp, LOCATION_EXTRA, 0, nil, mg)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SynchroSummon(tp, sg:GetFirst(), nil, mg)
  	end
  end
  
  