Advanced
This card is used to Ritual Summon any 1 Ritual Monster. You must also send Normal Monsters from your Deck to the GY whose total Levels equal the Level of that Ritual Monster.
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.filter(c, e, tp, m)
	if bit.band(c:GetType(), 0x81) ~= 0x81 or not c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_RITUAL, tp, false, true) then
		return false
	end
	if c.mat_filter then
		m = m:Filter(c.mat_filter, nil, tp)
	end
	return m:CheckWithSumEqual(Card.GetRitualLevel, c:GetLevel(), 1, 99, c)
end
function s.matfilter(c)
	return c:IsType(TYPE_NORMAL) and c:IsAbleToGrave()
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
			return false
		end
		local mg = Duel.GetMatchingGroup(s.matfilter, tp, LOCATION_DECK, 0, nil)
		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, e, tp, mg)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
		return
	end
	::cancel::
	local mg = Duel.GetMatchingGroup(s.matfilter, tp, LOCATION_DECK, 0, nil)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local tg = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, mg)
	if tg:GetCount() > 0 then
		local tc = tg:GetFirst()
		if tc.mat_filter then
			mg = mg:Filter(tc.mat_filter, nil, tp)
		end
		local lv = tc:GetLevel()
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		aux.GCheckAdditional = function(sg)
			return sg:GetSum(Card.GetRitualLevel, tc) <= lv
		end
		local mat = mg:SelectSubGroup(tp, aux.RitualCheckEqual, true, 1, 99, tc, lv)
		aux.GCheckAdditional = nil
		if not mat then
			goto cancel
		end
		tc:SetMaterial(mat)
		Duel.SendtoGrave(mat, REASON_EFFECT + REASON_MATERIAL + REASON_RITUAL)
		Duel.BreakEffect()
		Duel.SpecialSummon(tc, SUMMON_TYPE_RITUAL, tp, tp, false, true, POS_FACEUP)
		tc:CompleteProcedure()
	end
end


Advanced
This card is used to Ritual Summon any 1 Ritual Monster. You must also send Normal Monsters from your Deck to the GY whose total Levels equal the Level of that Ritual Monster.
-- Advanced
local s, id, o = GetID()
function s.initial_effect(c)
	--Activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.filter(c, e, tp, m)
	if bit.band(c:GetType(), 0x81) ~= 0x81 or not c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_RITUAL, tp, false, true) then
		return false
	end
	if c.mat_filter then
		m = m:Filter(c.mat_filter, nil, tp)
	end
	return m:CheckWithSumEqual(Card.GetRitualLevel, c:GetLevel(), 1, 99, c)
end
function s.matfilter(c)
	return c:IsType(TYPE_NORMAL) and c:IsAbleToGrave()
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
			return false
		end
		local mg = Duel.GetMatchingGroup(s.matfilter, tp, LOCATION_DECK, 0, nil)
		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, e, tp, mg)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
		return
	end
	::cancel::
	local mg = Duel.GetMatchingGroup(s.matfilter, tp, LOCATION_DECK, 0, nil)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
	local tg = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, mg)
	if tg:GetCount() > 0 then
		local tc = tg:GetFirst()
		if tc.mat_filter then
			mg = mg:Filter(tc.mat_filter, nil, tp)
		end
		local lv = tc:GetLevel()
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		aux.GCheckAdditional = function(sg)
			return sg:GetSum(Card.GetRitualLevel, tc) <= lv
		end
		local mat = mg:SelectSubGroup(tp, aux.RitualCheckEqual, true, 1, 99, tc, lv)
		aux.GCheckAdditional = nil
		if not mat then
			goto cancel
		end
		tc:SetMaterial(mat)
		Duel.SendtoGrave(mat, REASON_EFFECT + REASON_MATERIAL + REASON_RITUAL)
		Duel.BreakEffect()
		Duel.SpecialSummon(tc, SUMMON_TYPE_RITUAL, tp, tp, false, true, POS_FACEUP)
		tc:CompleteProcedure()
	end
end

