Spiritual
Once per turn, during your Main Phase: You can banish 1 "Ritual Beast" monster from your Extra Deck and send 1 "Ritual Beast" monster with the same Type as that monster from your Deck to the GY. You can only Special Summon "Spiritual Beast Rampengu(s)" once per turn.
local SETCARD_ID_0 = 0xb5 --Ritual

local SETCARD_ID_0 = 0xb5 --Ritual
local s, id, o = GetID()
function s.initial_effect(c)
	c:SetSPSummonOnce(id)
	--tohand
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_TOGRAVE)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.tgfilter(c, rac)
	return c:IsSetCard(SETCARD_ID_0) and c:IsRace(rac) and c:IsAbleToGrave()
end
function s.rmfilter(c, tp)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove() and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil, c:GetRace())
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.rmfilter, tp, LOCATION_EXTRA, 0, 1, nil, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, tp, LOCATION_EXTRA)
	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local g = Duel.SelectMatchingCard(tp, s.rmfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, tp)
	if g:GetCount() > 0 and Duel.Remove(g, POS_FACEUP, REASON_EFFECT) ~= 0 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		local sg = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil, g:GetFirst():GetRace())
		Duel.SendtoGrave(sg, REASON_EFFECT)
	end
end


Spiritual
Once per turn, during your Main Phase: You can banish 1 "Ritual Beast" monster from your Extra Deck and send 1 "Ritual Beast" monster with the same Type as that monster from your Deck to the GY. You can only Special Summon "Spiritual Beast Rampengu(s)" once per turn.
-- Spiritual
local SETCARD_ID_0 = 0xb5 --Ritual
local s, id, o = GetID()
function s.initial_effect(c)
	c:SetSPSummonOnce(id)
	--tohand
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_TOGRAVE)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.tgfilter(c, rac)
	return c:IsSetCard(SETCARD_ID_0) and c:IsRace(rac) and c:IsAbleToGrave()
end
function s.rmfilter(c, tp)
	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove() and Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil, c:GetRace())
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.rmfilter, tp, LOCATION_EXTRA, 0, 1, nil, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, tp, LOCATION_EXTRA)
	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
	local g = Duel.SelectMatchingCard(tp, s.rmfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, tp)
	if g:GetCount() > 0 and Duel.Remove(g, POS_FACEUP, REASON_EFFECT) ~= 0 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
		local sg = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil, g:GetFirst():GetRace())
		Duel.SendtoGrave(sg, REASON_EFFECT)
	end
end

