name: Dawn
card_text: This card is used to Ritual Summon "Herald of Perfection". You must also Tribute monsters from your hand or field whose total Levels equal exactly 6. When "Herald of Perfection" is Ritual Summoned by this card's effect: You can banish this card from your Graveyard, then target 1 of the monsters in your Graveyard that was Tributed for that Ritual Summon; return that target to your hand.
external_ids: local CARD_ID_0 = 44665365 --Herald of Perfection
  
lua: local CARD_ID_0 = 44665365 --Herald of Perfection
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	aux.AddRitualProcEqualCode(c, CARD_ID_0, nil, nil, nil, false, s.extraop)
  	--salvage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_CUSTOM + id)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetCost(s.thcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.extraop(e, tp, eg, ep, ev, re, r, rp, tc, mat)
  	if not tc then
  		return
  	end
  	e:SetLabelObject(tc)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAIN_END)
  	e1:SetOperation(s.evop)
  	e1:SetLabelObject(e)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:GetHandler() == e:GetHandler()
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsAbleToRemove()
  	end
  	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_COST)
  end
  function s.thfilter(c, e, tp)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(tp) and c:IsReason(REASON_RELEASE) and c:IsAbleToHand() and c:IsCanBeEffectTarget(e)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tc = eg:GetFirst()
  	local mat = tc:GetMaterial()
  	if chkc then
  		return mat:IsContains(chkc) and s.thfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return mat:IsExists(s.thfilter, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = mat:FilterSelect(tp, s.thfilter, 1, 1, nil, e, tp)
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	end
  end
  function s.evop(e, tp, eg, ep, ev, re, r, rp)
  	local te = e:GetLabelObject()
  	local tc = te:GetLabelObject()
  	Duel.RaiseEvent(tc, EVENT_CUSTOM + id, te, 0, tp, tp, 0)
  	te:SetLabelObject(nil)
  	e:Reset()
  end
  
  
source_text: Dawn
  This card is used to Ritual Summon "Herald of Perfection". You must also Tribute monsters from your hand or field whose total Levels equal exactly 6. When "Herald of Perfection" is Ritual Summoned by this card's effect: You can banish this card from your Graveyard, then target 1 of the monsters in your Graveyard that was Tributed for that Ritual Summon; return that target to your hand.
target_text: -- Dawn
  local CARD_ID_0 = 44665365 --Herald of Perfection
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	aux.AddRitualProcEqualCode(c, CARD_ID_0, nil, nil, nil, false, s.extraop)
  	--salvage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_TOHAND)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_CUSTOM + id)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCondition(s.thcon)
  	e2:SetCost(s.thcost)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.extraop(e, tp, eg, ep, ev, re, r, rp, tc, mat)
  	if not tc then
  		return
  	end
  	e:SetLabelObject(tc)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_CHAIN_END)
  	e1:SetOperation(s.evop)
  	e1:SetLabelObject(e)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.thcon(e, tp, eg, ep, ev, re, r, rp)
  	return re:GetHandler() == e:GetHandler()
  end
  function s.thcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsAbleToRemove()
  	end
  	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_COST)
  end
  function s.thfilter(c, e, tp)
  	return c:IsLocation(LOCATION_GRAVE) and c:IsControler(tp) and c:IsReason(REASON_RELEASE) and c:IsAbleToHand() and c:IsCanBeEffectTarget(e)
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local tc = eg:GetFirst()
  	local mat = tc:GetMaterial()
  	if chkc then
  		return mat:IsContains(chkc) and s.thfilter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return mat:IsExists(s.thfilter, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g = mat:FilterSelect(tp, s.thfilter, 1, 1, nil, e, tp)
  	Duel.SetTargetCard(g)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g, g:GetCount(), 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc and tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	end
  end
  function s.evop(e, tp, eg, ep, ev, re, r, rp)
  	local te = e:GetLabelObject()
  	local tc = te:GetLabelObject()
  	Duel.RaiseEvent(tc, EVENT_CUSTOM + id, te, 0, tp, tp, 0)
  	te:SetLabelObject(nil)
  	e:Reset()
  end
  
  