name: Linkross
card_text: 1 Link-2 or higher Link Monster
  If this card is Link Summoned: You can activate this effect; Special Summon a number of "Link Tokens" (Cyberse/LIGHT/Level 1/ATK 0/DEF 0) up to the Link Rating of the monster used for this card's Link Summon, also you cannot use "Link Tokens" as Link Material for the rest of this turn. You can only use this effect of "Linkross" once per turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 85243785 --Link Token
  local CARD_ID_2 = 48068379 --Link Token
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 85243785 --Link Token
  local CARD_ID_2 = 48068379 --Link Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, s.mfilter, 1)
  	--token
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOKEN + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.tkcon)
  	e1:SetTarget(s.tktg)
  	e1:SetOperation(s.tkop)
  	c:RegisterEffect(e1)
  end
  function s.mfilter(c)
  	return c:IsLinkType(TYPE_LINK) and c:GetLink() >= 2
  end
  function s.tkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local mg = e:GetHandler():GetMaterial()
  	if mg:GetCount() ~= 1 then
  		return false
  	end
  	if chk == 0 then
  		return mg:IsExists(Card.IsType, 1, nil, TYPE_LINK)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, 0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_CYBERSE, ATTRIBUTE_LIGHT)
  	end
  	e:SetLabel(mg:GetFirst():GetLink())
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local ct = e:GetLabel()
  	if ft > 0 and ct > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, 0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_CYBERSE, ATTRIBUTE_LIGHT) then
  		local count = math.min(ft, ct)
  		if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  			count = 1
  		end
  		if count > 1 then
  			local num = {}
  			local i = 1
  			while i <= count do
  				num[i] = i
  				i = i + 1
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  			count = 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)
  			count = count - 1
  		until count == 0
  		Duel.SpecialSummonComplete()
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  	e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetTargetRange(0xff, 0xff)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsCode, CARD_ID_2))
  	e1:SetValue(s.lklimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.lklimit(e, c)
  	if not c then
  		return false
  	end
  	return c:IsControler(e:GetHandlerPlayer())
  end
  
  
source_text: Linkross
  1 Link-2 or higher Link Monster
  If this card is Link Summoned: You can activate this effect; Special Summon a number of "Link Tokens" (Cyberse/LIGHT/Level 1/ATK 0/DEF 0) up to the Link Rating of the monster used for this card's Link Summon, also you cannot use "Link Tokens" as Link Material for the rest of this turn. You can only use this effect of "Linkross" once per turn.
target_text: -- Linkross
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 85243785 --Link Token
  local CARD_ID_2 = 48068379 --Link Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, s.mfilter, 1)
  	--token
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOKEN + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.tkcon)
  	e1:SetTarget(s.tktg)
  	e1:SetOperation(s.tkop)
  	c:RegisterEffect(e1)
  end
  function s.mfilter(c)
  	return c:IsLinkType(TYPE_LINK) and c:GetLink() >= 2
  end
  function s.tkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.tktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local mg = e:GetHandler():GetMaterial()
  	if mg:GetCount() ~= 1 then
  		return false
  	end
  	if chk == 0 then
  		return mg:IsExists(Card.IsType, 1, nil, TYPE_LINK)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, 0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_CYBERSE, ATTRIBUTE_LIGHT)
  	end
  	e:SetLabel(mg:GetFirst():GetLink())
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.tkop(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local ct = e:GetLabel()
  	if ft > 0 and ct > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, CARD_ID_2, 0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_CYBERSE, ATTRIBUTE_LIGHT) then
  		local count = math.min(ft, ct)
  		if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  			count = 1
  		end
  		if count > 1 then
  			local num = {}
  			local i = 1
  			while i <= count do
  				num[i] = i
  				i = i + 1
  			end
  			Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  			count = 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)
  			count = count - 1
  		until count == 0
  		Duel.SpecialSummonComplete()
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  	e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetTargetRange(0xff, 0xff)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsCode, CARD_ID_2))
  	e1:SetValue(s.lklimit)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.lklimit(e, c)
  	if not c then
  		return false
  	end
  	return c:IsControler(e:GetHandlerPlayer())
  end
  
  