name: Spool
card_text: When an opponent's monster declares a direct attack, while you have 3 or more Cyberse monsters in your GY: Negate the attack, then, you can Special Summon up to 3 "Spool Tokens" (Cyberse/LIGHT/Level 1/ATK 0/DEF 0) in Defense Position. These Tokens cannot be Tributed for a Tribute Summon.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 2625940 --Spool Token
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 2625940 --Spool Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:GetFirst():IsControler(1 - tp) and Duel.GetAttackTarget() == nil and Duel.IsExistingMatchingCard(Card.IsRace, tp, LOCATION_GRAVE, 0, 3, nil, RACE_CYBERSE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = math.min((Duel.GetLocationCount(tp, LOCATION_MZONE)), 3)
  	if
  		Duel.NegateAttack()
  		and ft > 0
  		and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_CYBERSE, ATTRIBUTE_LIGHT, POS_FACEUP_DEFENSE)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  	then
  		Duel.BreakEffect()
  		if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  			ft = 1
  		end
  		local ct = 1
  		if ft > 1 then
  			local num = {}
  			local i = 1
  			while i <= ft do
  				num[i] = i
  				i = i + 1
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  			ct = Duel.AnnounceNumber(tp, table.unpack(num))
  		end
  		repeat
  			local token = Duel.CreateToken(tp, id + 1)
  			Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetValue(1)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			token:RegisterEffect(e1, true)
  			ct = ct - 1
  		until ct == 0
  		Duel.SpecialSummonComplete()
  	end
  end
  
  
source_text: Spool
  When an opponent's monster declares a direct attack, while you have 3 or more Cyberse monsters in your GY: Negate the attack, then, you can Special Summon up to 3 "Spool Tokens" (Cyberse/LIGHT/Level 1/ATK 0/DEF 0) in Defense Position. These Tokens cannot be Tributed for a Tribute Summon.
target_text: -- Spool
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 2625940 --Spool Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e1:SetCondition(s.condition)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return eg:GetFirst():IsControler(1 - tp) and Duel.GetAttackTarget() == nil and Duel.IsExistingMatchingCard(Card.IsRace, tp, LOCATION_GRAVE, 0, 3, nil, RACE_CYBERSE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = math.min((Duel.GetLocationCount(tp, LOCATION_MZONE)), 3)
  	if
  		Duel.NegateAttack()
  		and ft > 0
  		and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_CYBERSE, ATTRIBUTE_LIGHT, POS_FACEUP_DEFENSE)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 0))
  	then
  		Duel.BreakEffect()
  		if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  			ft = 1
  		end
  		local ct = 1
  		if ft > 1 then
  			local num = {}
  			local i = 1
  			while i <= ft do
  				num[i] = i
  				i = i + 1
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  			ct = Duel.AnnounceNumber(tp, table.unpack(num))
  		end
  		repeat
  			local token = Duel.CreateToken(tp, id + 1)
  			Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  			e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e1:SetValue(1)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			token:RegisterEffect(e1, true)
  			ct = ct - 1
  		until ct == 0
  		Duel.SpecialSummonComplete()
  	end
  end
  
  