name: Traptrix
card_text: 1 non-Link "Traptrix" monster
  This Link Summoned card is unaffected by Trap effects. You can only use each of the following effects of "Traptrix Sera" once per turn, and not during the Damage Step.
  ● If a Normal Trap Card is activated: You can Special Summon 1 "Traptrix" monster from your Deck with a different name than the cards you control.
  ● If your other "Traptrix" monster's effect is activated: You can Set 1 "Hole" Normal Trap directly from the Deck.
external_ids: local SETCARD_ID_0 = 0x108a --Traptrix
  local SETCARD_ID_1 = 0x4c --Trap
  
lua: local SETCARD_ID_0 = 0x108a --Traptrix
  local SETCARD_ID_1 = 0x4c --Trap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, s.matfilter, 1, 1)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.imcon)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--set
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCode(EVENT_CHAINING)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1, id + 1)
  	e4:SetCondition(s.setcon)
  	e4:SetTarget(s.settg)
  	e4:SetOperation(s.setop)
  	c:RegisterEffect(e4)
  end
  function s.matfilter(c)
  	return c:IsLinkSetCard(SETCARD_ID_1) and not c:IsLinkType(TYPE_LINK)
  end
  function s.imcon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.efilter(e, te)
  	return te:IsActiveType(TYPE_TRAP)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:GetHandler():GetType() == TYPE_TRAP
  end
  function s.cfilter(c, code)
  	return c:IsFaceup() and c:IsCode(code)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil, c:GetCode())
  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.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.setcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = re:GetHandler()
  	return re:IsActiveType(TYPE_MONSTER) and rc ~= c and rc:IsSetCard(SETCARD_ID_1) and rc:IsControler(tp)
  end
  function s.setfilter(c)
  	return c:IsSetCard(SETCARD_ID_1, 0x89) and c:GetType() == TYPE_TRAP and c:IsSSetable()
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SSet(tp, tc)
  	end
  end
  
  
source_text: Traptrix
  1 non-Link "Traptrix" monster
  This Link Summoned card is unaffected by Trap effects. You can only use each of the following effects of "Traptrix Sera" once per turn, and not during the Damage Step.
  ● If a Normal Trap Card is activated: You can Special Summon 1 "Traptrix" monster from your Deck with a different name than the cards you control.
  ● If your other "Traptrix" monster's effect is activated: You can Set 1 "Hole" Normal Trap directly from the Deck.
target_text: -- Traptrix
  local SETCARD_ID_0 = 0x108a --Traptrix
  local SETCARD_ID_1 = 0x4c --Trap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, s.matfilter, 1, 1)
  	c:EnableReviveLimit()
  	--immune
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetCode(EFFECT_IMMUNE_EFFECT)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.imcon)
  	e1:SetValue(s.efilter)
  	c:RegisterEffect(e1)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_CHAINING)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.spcon)
  	e3:SetTarget(s.sptg)
  	e3:SetOperation(s.spop)
  	c:RegisterEffect(e3)
  	--set
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetProperty(EFFECT_FLAG_DELAY)
  	e4:SetCode(EVENT_CHAINING)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1, id + 1)
  	e4:SetCondition(s.setcon)
  	e4:SetTarget(s.settg)
  	e4:SetOperation(s.setop)
  	c:RegisterEffect(e4)
  end
  function s.matfilter(c)
  	return c:IsLinkSetCard(SETCARD_ID_1) and not c:IsLinkType(TYPE_LINK)
  end
  function s.imcon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.efilter(e, te)
  	return te:IsActiveType(TYPE_TRAP)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:GetHandler():GetType() == TYPE_TRAP
  end
  function s.cfilter(c, code)
  	return c:IsFaceup() and c:IsCode(code)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_ONFIELD, 0, 1, nil, c:GetCode())
  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.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.setcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = re:GetHandler()
  	return re:IsActiveType(TYPE_MONSTER) and rc ~= c and rc:IsSetCard(SETCARD_ID_1) and rc:IsControler(tp)
  end
  function s.setfilter(c)
  	return c:IsSetCard(SETCARD_ID_1, 0x89) and c:GetType() == TYPE_TRAP and c:IsSSetable()
  end
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  end
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  	local g = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.SSet(tp, tc)
  	end
  end
  
  