name: Steelswarm
card_text: 2 "lswarm" monsters
  While this card is in the Extra Monster Zone, if a monster would be Special Summoned from the Extra Deck to the Main Monster Zone, it must be Summoned in the zone this card points to. While this card points to a monster, neither player can target it with card effects, also it cannot be destroyed by battle or card effects. Once per turn, when a monster(s) on the field is destroyed by battle or by card effect: You can Special Summon Level 4 or lower "lswarm" monsters from your Deck in Defense Position, up to the number destroyed.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xa --lswarm
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xa --lswarm
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
  	c:EnableReviveLimit()
  	--force mzone
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_MUST_USE_MZONE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_EXTRA, LOCATION_EXTRA)
  	e1:SetCondition(s.frccon)
  	e1:SetValue(s.frcval)
  	c:RegisterEffect(e1)
  	--cannot be target/indestructable
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.indcon)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	c:RegisterEffect(e4)
  	local e5 = e3:Clone()
  	e5:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e5)
  	--special summon
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e6:SetCode(EVENT_DESTROYED)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e6:SetCountLimit(1)
  	e6:SetCondition(s.spcon)
  	e6:SetTarget(s.sptg)
  	e6:SetOperation(s.spop)
  	c:RegisterEffect(e6)
  end
  function s.frccon(e)
  	return e:GetHandler():GetSequence() > 4
  end
  function s.frcval(e, c, fp, rp, r)
  	return e:GetHandler():GetLinkedZone() | 0x600060
  end
  function s.indcon(e)
  	return e:GetHandler():GetLinkedGroupCount() > 0
  end
  function s.cfilter(c)
  	return c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  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
  	local ct = eg:FilterCount(s.cfilter, nil)
  	e:SetLabel(ct)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	ft = math.min(ft, e:GetLabel())
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, ft, nil, e, tp)
  	Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  end
  
  
source_text: Steelswarm
  2 "lswarm" monsters
  While this card is in the Extra Monster Zone, if a monster would be Special Summoned from the Extra Deck to the Main Monster Zone, it must be Summoned in the zone this card points to. While this card points to a monster, neither player can target it with card effects, also it cannot be destroyed by battle or card effects. Once per turn, when a monster(s) on the field is destroyed by battle or by card effect: You can Special Summon Level 4 or lower "lswarm" monsters from your Deck in Defense Position, up to the number destroyed.
target_text: -- Steelswarm
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local SETCARD_ID_0 = 0xa --lswarm
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
  	c:EnableReviveLimit()
  	--force mzone
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_MUST_USE_MZONE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(LOCATION_EXTRA, LOCATION_EXTRA)
  	e1:SetCondition(s.frccon)
  	e1:SetValue(s.frcval)
  	c:RegisterEffect(e1)
  	--cannot be target/indestructable
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.indcon)
  	e3:SetValue(1)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	c:RegisterEffect(e4)
  	local e5 = e3:Clone()
  	e5:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e5)
  	--special summon
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e6:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e6:SetCode(EVENT_DESTROYED)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e6:SetCountLimit(1)
  	e6:SetCondition(s.spcon)
  	e6:SetTarget(s.sptg)
  	e6:SetOperation(s.spop)
  	c:RegisterEffect(e6)
  end
  function s.frccon(e)
  	return e:GetHandler():GetSequence() > 4
  end
  function s.frcval(e, c, fp, rp, r)
  	return e:GetHandler():GetLinkedZone() | 0x600060
  end
  function s.indcon(e)
  	return e:GetHandler():GetLinkedGroupCount() > 0
  end
  function s.cfilter(c)
  	return c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.cfilter, 1, nil)
  end
  function s.spfilter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  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
  	local ct = eg:FilterCount(s.cfilter, nil)
  	e:SetLabel(ct)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	ft = math.min(ft, e:GetLabel())
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, ft, nil, e, tp)
  	Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  end
  
  