name: Trickstar
card_text: When this card is activated: You can add 1 "Trickstar" monster from your GY to your hand. You can only use each of the following effects of "Trickstar Live Stage" once per turn, also you cannot Special Summon monsters the turn you activate these effects, except "Trickstar" monsters (even if this card leaves the field).
  ● If you control a "Trickstar" Link Monster: You can Special Summon 1 "Trickstar Token" (Fairy/LIGHT/Level 1/ATK 0/DEF 0).
  ● If your opponent controls a card in their Spell & Trap Zone: You can Special Summon 1 "Trickstar Token".
external_ids: local CARD_ID_0 = 51208047 --Shiranui Token
  local SETCARD_ID_0 = 0xfb --Trickstar
  
lua: local CARD_ID_0 = 51208047 --Shiranui Token
  local SETCARD_ID_0 = 0xfb --Trickstar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--token
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.cost)
  	e2:SetCondition(s.spcon1)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon2)
  	c:RegisterEffect(e3)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabelObject(e)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_GRAVE, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  	end
  end
  function s.cfilter1(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.spcon1(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter1, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.cfilter2(c)
  	return c:GetSequence() < 5
  end
  function s.spcon2(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter2, tp, 0, LOCATION_SZONE, 1, nil)
  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.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_FAIRY, ATTRIBUTE_LIGHT)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if
  		Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0
  		or not e:GetHandler():IsRelateToEffect(e)
  		or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_FAIRY, ATTRIBUTE_LIGHT)
  	then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	Duel.SpecialSummon(token, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  
source_text: Trickstar
  When this card is activated: You can add 1 "Trickstar" monster from your GY to your hand. You can only use each of the following effects of "Trickstar Live Stage" once per turn, also you cannot Special Summon monsters the turn you activate these effects, except "Trickstar" monsters (even if this card leaves the field).
  ● If you control a "Trickstar" Link Monster: You can Special Summon 1 "Trickstar Token" (Fairy/LIGHT/Level 1/ATK 0/DEF 0).
  ● If your opponent controls a card in their Spell & Trap Zone: You can Special Summon 1 "Trickstar Token".
target_text: -- Trickstar
  local CARD_ID_0 = 51208047 --Shiranui Token
  local SETCARD_ID_0 = 0xfb --Trickstar
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--token
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.cost)
  	e2:SetCondition(s.spcon1)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon2)
  	c:RegisterEffect(e3)
  	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
  end
  function s.counterfilter(c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetTargetRange(1, 0)
  	e1:SetLabelObject(e)
  	e1:SetTarget(s.splimit)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.thfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_GRAVE, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  	end
  end
  function s.cfilter1(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.spcon1(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter1, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.cfilter2(c)
  	return c:GetSequence() < 5
  end
  function s.spcon2(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter2, tp, 0, LOCATION_SZONE, 1, nil)
  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.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_FAIRY, ATTRIBUTE_LIGHT)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if
  		Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0
  		or not e:GetHandler():IsRelateToEffect(e)
  		or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, SETCARD_ID_0, TYPES_TOKEN_MONSTER, 0, 0, 1, RACE_FAIRY, ATTRIBUTE_LIGHT)
  	then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	Duel.SpecialSummon(token, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  