name: The
card_text: If this card is Normal or Special Summoned: You can take 1 "Temple of the Kings", or 1 Spell/Trap that mentions it, from your Deck and either add it to your hand or send it to the GY. You can only use this effect of "The Man with the Mark" once per turn. While you control "Temple of the Kings", this card and "Apophis" monsters you control cannot be destroyed by battle or card effects. "Temple of the Kings" you control cannot be destroyed by card effects.
external_ids: local CARD_ID_0 = 29762407 --Temple of the Kings
  local SETCARD_ID_0 = 0x1c8 --Apophis
  
lua: local CARD_ID_0 = 29762407 --Temple of the Kings
  local SETCARD_ID_0 = 0x1c8 --Apophis
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_DECKDES + CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--monster indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetCondition(s.indcon)
  	e3:SetTarget(s.indtg)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e4)
  	--indes
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetTargetRange(LOCATION_ONFIELD, 0)
  	e5:SetTarget(s.indtg2)
  	e5:SetValue(1)
  	c:RegisterEffect(e5)
  end
  function s.thfilter(c)
  	return (c:IsCode(CARD_ID_0) or aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP)) and (c:IsAbleToHand() or c:IsAbleToGrave())
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() <= 0 then
  		return
  	end
  	local tc = g:GetFirst()
  	if tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp, 1190, 1191) == 0) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	elseif tc:IsAbleToGrave() then
  		Duel.SendtoGrave(tc, REASON_EFFECT)
  	end
  end
  function s.indcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup, Card.IsCode), e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil, CARD_ID_0)
  end
  function s.indtg(e, c)
  	return c:IsSetCard(SETCARD_ID_0) or e:GetHandler() == c
  end
  function s.indtg2(e, c)
  	return c:IsCode(CARD_ID_0)
  end
  
  
source_text: The
  If this card is Normal or Special Summoned: You can take 1 "Temple of the Kings", or 1 Spell/Trap that mentions it, from your Deck and either add it to your hand or send it to the GY. You can only use this effect of "The Man with the Mark" once per turn. While you control "Temple of the Kings", this card and "Apophis" monsters you control cannot be destroyed by battle or card effects. "Temple of the Kings" you control cannot be destroyed by card effects.
target_text: -- The
  local CARD_ID_0 = 29762407 --Temple of the Kings
  local SETCARD_ID_0 = 0x1c8 --Apophis
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND + CATEGORY_DECKDES + CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--monster indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetCondition(s.indcon)
  	e3:SetTarget(s.indtg)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e4)
  	--indes
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetTargetRange(LOCATION_ONFIELD, 0)
  	e5:SetTarget(s.indtg2)
  	e5:SetValue(1)
  	c:RegisterEffect(e5)
  end
  function s.thfilter(c)
  	return (c:IsCode(CARD_ID_0) or aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP)) and (c:IsAbleToHand() or c:IsAbleToGrave())
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() <= 0 then
  		return
  	end
  	local tc = g:GetFirst()
  	if tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp, 1190, 1191) == 0) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	elseif tc:IsAbleToGrave() then
  		Duel.SendtoGrave(tc, REASON_EFFECT)
  	end
  end
  function s.indcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(aux.AND(Card.IsFaceup, Card.IsCode), e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil, CARD_ID_0)
  end
  function s.indtg(e, c)
  	return c:IsSetCard(SETCARD_ID_0) or e:GetHandler() == c
  end
  function s.indtg2(e, c)
  	return c:IsCode(CARD_ID_0)
  end
  
  