name: Genex
card_text: 1 "Genex" Tuner + 1+ non-Tuner monsters
  Once per turn: You can discard 1 card, then target 1 Level 4 or lower Machine monster in your GY; Special Summon that target, and if you do, its ATK becomes doubled until the end of this turn, it cannot attack your opponent directly, also banish it during your End Phase.
external_ids: local SETCARD_ID_0 = 0x2 --Genex
  
lua: local SETCARD_ID_0 = 0x2 --Genex
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.spfilter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsRace(RACE_MACHINE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or not tc:IsRace(RACE_MACHINE) or not tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return
  	end
  	if Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		local atk = tc:GetBaseAttack()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK)
  		e1:SetValue(atk * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD)
  		tc:RegisterEffect(e2)
  		local e3 = Effect.CreateEffect(e:GetHandler())
  		e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e3:SetRange(LOCATION_MZONE)
  		e3:SetCode(EVENT_PHASE + PHASE_END)
  		e3:SetCondition(s.rmcon)
  		e3:SetOperation(s.rmop)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD)
  		e3:SetCountLimit(1)
  		tc:RegisterEffect(e3)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_EFFECT)
  end
  
  
source_text: Genex
  1 "Genex" Tuner + 1+ non-Tuner monsters
  Once per turn: You can discard 1 card, then target 1 Level 4 or lower Machine monster in your GY; Special Summon that target, and if you do, its ATK becomes doubled until the end of this turn, it cannot attack your opponent directly, also banish it during your End Phase.
target_text: -- Genex
  local SETCARD_ID_0 = 0x2 --Genex
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.spfilter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsRace(RACE_MACHINE) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.spfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or not tc:IsRace(RACE_MACHINE) or not tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return
  	end
  	if Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP) then
  		local atk = tc:GetBaseAttack()
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_ATTACK)
  		e1:SetValue(atk * 2)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD)
  		tc:RegisterEffect(e2)
  		local e3 = Effect.CreateEffect(e:GetHandler())
  		e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e3:SetRange(LOCATION_MZONE)
  		e3:SetCode(EVENT_PHASE + PHASE_END)
  		e3:SetCondition(s.rmcon)
  		e3:SetOperation(s.rmop)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TOFIELD)
  		e3:SetCountLimit(1)
  		tc:RegisterEffect(e3)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.rmcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_EFFECT)
  end
  
  