name: Materiactor
card_text: You can discard 1 card; Special Summon 1 Level 3 Normal Monster from your hand or Deck, or if you discarded a Normal Monster to activate this effect, you can Special Summon 1 "Materiactor" monster instead. You can only use this effect of "Materiactor Gigadra" once per turn. You cannot Special Summon monsters from the Extra Deck, except Xyz Monsters.
external_ids: local SETCARD_ID_0 = 0x160 --Materiactor
  
lua: local SETCARD_ID_0 = 0x160 --Materiactor
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--splimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(1, 0)
  	e2:SetTarget(s.splimit)
  	c:RegisterEffect(e2)
  end
  function s.costfilter(c, e, tp)
  	return c:IsDiscardable() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, c, e, tp, c:IsType(TYPE_NORMAL))
  end
  function s.spfilter(c, e, tp, normal)
  	return (normal and c:IsSetCard(SETCARD_ID_0) or c:IsLevel(3) and c:IsType(TYPE_NORMAL)) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100, 0)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local sg = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if sg:GetFirst():IsType(TYPE_NORMAL) then
  		e:SetLabel(100, 1)
  	else
  		e:SetLabel(100, 0)
  	end
  	Duel.SendtoGrave(sg, REASON_COST + REASON_DISCARD)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local check, label = e:GetLabel()
  	if chk == 0 then
  		e:SetLabel(0, 0)
  		return check == 100 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	e:SetLabel(0, label)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local check, label = e:GetLabel()
  	local normal = label == 1
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, e, tp, normal)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp)
  	return c:IsLocation(LOCATION_EXTRA) and not c:IsType(TYPE_XYZ)
  end
  
  
source_text: Materiactor
  You can discard 1 card; Special Summon 1 Level 3 Normal Monster from your hand or Deck, or if you discarded a Normal Monster to activate this effect, you can Special Summon 1 "Materiactor" monster instead. You can only use this effect of "Materiactor Gigadra" once per turn. You cannot Special Summon monsters from the Extra Deck, except Xyz Monsters.
target_text: -- Materiactor
  local SETCARD_ID_0 = 0x160 --Materiactor
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--splimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTargetRange(1, 0)
  	e2:SetTarget(s.splimit)
  	c:RegisterEffect(e2)
  end
  function s.costfilter(c, e, tp)
  	return c:IsDiscardable() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, c, e, tp, c:IsType(TYPE_NORMAL))
  end
  function s.spfilter(c, e, tp, normal)
  	return (normal and c:IsSetCard(SETCARD_ID_0) or c:IsLevel(3) and c:IsType(TYPE_NORMAL)) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100, 0)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local sg = Duel.SelectMatchingCard(tp, s.costfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if sg:GetFirst():IsType(TYPE_NORMAL) then
  		e:SetLabel(100, 1)
  	else
  		e:SetLabel(100, 0)
  	end
  	Duel.SendtoGrave(sg, REASON_COST + REASON_DISCARD)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local check, label = e:GetLabel()
  	if chk == 0 then
  		e:SetLabel(0, 0)
  		return check == 100 and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	end
  	e:SetLabel(0, label)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local check, label = e:GetLabel()
  	local normal = label == 1
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil, e, tp, normal)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp)
  	return c:IsLocation(LOCATION_EXTRA) and not c:IsType(TYPE_XYZ)
  end
  
  