name: Stardust
card_text: Select 1 Dragon-Type Synchro Monster in your Graveyard. Remove from play other monsters in your Graveyard whose total Levels equal the Level of the selected monster and Special Summon it from the Graveyard.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp, rg)
  	if not c:IsType(TYPE_SYNCHRO) or not c:IsRace(RACE_DRAGON) or not c:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return false
  	end
  	local result = false
  	if rg:IsContains(c) then
  		rg:RemoveCard(c)
  		result = rg:CheckWithSumEqual(Card.GetLevel, c:GetLevel(), 1, 99)
  		rg:AddCard(c)
  	else
  		result = rg:CheckWithSumEqual(Card.GetLevel, c:GetLevel(), 1, 99)
  	end
  	return result
  end
  function s.rmfilter(c)
  	return c:GetLevel() > 0 and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  			return false
  		end
  		local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  		return Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, rg)
  	end
  	local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, rg)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or not tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return
  	end
  	local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  	rg:RemoveCard(tc)
  	if rg:CheckWithSumEqual(Card.GetLevel, tc:GetLevel(), 1, 99) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local rm = rg:SelectWithSumEqual(tp, Card.GetLevel, tc:GetLevel(), 1, 99)
  		Duel.Remove(rm, POS_FACEUP, REASON_EFFECT)
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Stardust
  Select 1 Dragon-Type Synchro Monster in your Graveyard. Remove from play other monsters in your Graveyard whose total Levels equal the Level of the selected monster and Special Summon it from the Graveyard.
target_text: -- Stardust
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.spfilter(c, e, tp, rg)
  	if not c:IsType(TYPE_SYNCHRO) or not c:IsRace(RACE_DRAGON) or not c:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return false
  	end
  	local result = false
  	if rg:IsContains(c) then
  		rg:RemoveCard(c)
  		result = rg:CheckWithSumEqual(Card.GetLevel, c:GetLevel(), 1, 99)
  		rg:AddCard(c)
  	else
  		result = rg:CheckWithSumEqual(Card.GetLevel, c:GetLevel(), 1, 99)
  	end
  	return result
  end
  function s.rmfilter(c)
  	return c:GetLevel() > 0 and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  			return false
  		end
  		local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  		return Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, rg)
  	end
  	local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, rg)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) or Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 or not tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) then
  		return
  	end
  	local rg = Duel.GetMatchingGroup(s.rmfilter, tp, LOCATION_GRAVE, 0, nil)
  	rg:RemoveCard(tc)
  	if rg:CheckWithSumEqual(Card.GetLevel, tc:GetLevel(), 1, 99) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local rm = rg:SelectWithSumEqual(tp, Card.GetLevel, tc:GetLevel(), 1, 99)
  		Duel.Remove(rm, POS_FACEUP, REASON_EFFECT)
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  