name: Scarm,
card_text: If you control a monster that is not a "Burning Abyss" monster, destroy this card. You can only use 1 of these effects of "Scarm, Malebranche of the Burning Abyss" per turn, and only once that turn.
  ● If you control no Spell/Trap Cards: You can Special Summon this card from your hand.
  ● During the End Phase, if this card is in the GY because it was sent there this turn: You can add 1 Level 3 DARK Fiend monster from your Deck to your hand, except "Scarm, Malebranche of the Burning Abyss".
external_ids: local SETCARD_ID_0 = 0xb1 --Burning
  
lua: local SETCARD_ID_0 = 0xb1 --Burning
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--self destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_SELF_DESTROY)
  	e1:SetCondition(s.sdcon)
  	c:RegisterEffect(e1)
  	--Special Summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.sscon)
  	e2:SetTarget(s.sstg)
  	e2:SetOperation(s.ssop)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetOperation(s.regop)
  	c:RegisterEffect(e3)
  	--search
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_PHASE + PHASE_END)
  	e4:SetCountLimit(1, id)
  	e4:SetRange(LOCATION_GRAVE)
  	e4:SetCondition(s.thcon)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.sdfilter(c)
  	return c:IsFacedown() or not c:IsSetCard(SETCARD_ID_0)
  end
  function s.sdcon(e)
  	return Duel.IsExistingMatchingCard(s.sdfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.sscon(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.sstg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.ssop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.thfilter(c)
  	return c:IsLevel(3) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_FIEND) and not c:IsCode(id) and c:IsAbleToHand()
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) > 0
  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
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: Scarm,
  If you control a monster that is not a "Burning Abyss" monster, destroy this card. You can only use 1 of these effects of "Scarm, Malebranche of the Burning Abyss" per turn, and only once that turn.
  ● If you control no Spell/Trap Cards: You can Special Summon this card from your hand.
  ● During the End Phase, if this card is in the GY because it was sent there this turn: You can add 1 Level 3 DARK Fiend monster from your Deck to your hand, except "Scarm, Malebranche of the Burning Abyss".
target_text: -- Scarm,
  local SETCARD_ID_0 = 0xb1 --Burning
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--self destroy
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_SELF_DESTROY)
  	e1:SetCondition(s.sdcon)
  	c:RegisterEffect(e1)
  	--Special Summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.sscon)
  	e2:SetTarget(s.sstg)
  	e2:SetOperation(s.ssop)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetOperation(s.regop)
  	c:RegisterEffect(e3)
  	--search
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 1))
  	e4:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e4:SetCode(EVENT_PHASE + PHASE_END)
  	e4:SetCountLimit(1, id)
  	e4:SetRange(LOCATION_GRAVE)
  	e4:SetCondition(s.thcon)
  	e4:SetTarget(s.thtg)
  	e4:SetOperation(s.thop)
  	c:RegisterEffect(e4)
  end
  function s.sdfilter(c)
  	return c:IsFacedown() or not c:IsSetCard(SETCARD_ID_0)
  end
  function s.sdcon(e)
  	return Duel.IsExistingMatchingCard(s.sdfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.filter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.sscon(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_ONFIELD, 0, 1, nil)
  end
  function s.sstg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.ssop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	c:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.thfilter(c)
  	return c:IsLevel(3) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_FIEND) and not c:IsCode(id) and c:IsAbleToHand()
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetFlagEffect(id) > 0
  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
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  