Destiny
Once per turn: You can excavate the top card of your Deck, and if it is a Normal Spell, send it to the GY, otherwise place it on the bottom of your Deck. During the Main Phase of your next turn, you can activate the effect of that Spell in your GY (even if you no longer control this face-up card).
local s, id, o = GetID()
function s.initial_effect(c)
	--
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_DECKDES)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetCountLimit(1)
	e1:SetRange(LOCATION_MZONE)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, 0, 0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
		return
	end
	Duel.ConfirmDecktop(tp, 1)
	local g = Duel.GetDecktopGroup(tp, 1)
	local tc = g:GetFirst()
	if tc:GetType() == TYPE_SPELL then
		Duel.DisableShuffleCheck()
		Duel.SendtoGrave(g, REASON_EFFECT)
		local ae = tc:GetActivateEffect()
		if tc:IsLocation(LOCATION_GRAVE) and ae then
			local e1 = Effect.CreateEffect(tc)
			e1:SetDescription(ae:GetDescription())
			e1:SetType(EFFECT_TYPE_IGNITION)
			e1:SetCountLimit(1)
			e1:SetRange(LOCATION_GRAVE)
			e1:SetReset(RESET_EVENT + 0x2fe0000 + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
			e1:SetCondition(s.spellcon)
			e1:SetTarget(s.spelltg)
			e1:SetOperation(s.spellop)
			tc:RegisterEffect(e1)
		end
	else
		Duel.MoveSequence(tc, SEQ_DECKBOTTOM)
	end
end
function s.spellcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():GetTurnID() ~= Duel.GetTurnCount()
end
function s.spelltg(e, tp, eg, ep, ev, re, r, rp, chk)
	local ae = e:GetHandler():GetActivateEffect()
	local ftg = ae:GetTarget()
	if chk == 0 then
		e:SetCostCheck(false)
		return not ftg or ftg(e, tp, eg, ep, ev, re, r, rp, chk)
	end
	if ae:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
	else
		e:SetProperty(0)
	end
	if ftg then
		e:SetCostCheck(false)
		ftg(e, tp, eg, ep, ev, re, r, rp, chk)
	end
end
function s.spellop(e, tp, eg, ep, ev, re, r, rp)
	local ae = e:GetHandler():GetActivateEffect()
	local fop = ae:GetOperation()
	fop(e, tp, eg, ep, ev, re, r, rp)
end


Destiny
Once per turn: You can excavate the top card of your Deck, and if it is a Normal Spell, send it to the GY, otherwise place it on the bottom of your Deck. During the Main Phase of your next turn, you can activate the effect of that Spell in your GY (even if you no longer control this face-up card).
-- Destiny
local s, id, o = GetID()
function s.initial_effect(c)
	--
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_DECKDES)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetCountLimit(1)
	e1:SetRange(LOCATION_MZONE)
	e1:SetTarget(s.target)
	e1:SetOperation(s.operation)
	c:RegisterEffect(e1)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
	end
	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, 0, 0)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
		return
	end
	Duel.ConfirmDecktop(tp, 1)
	local g = Duel.GetDecktopGroup(tp, 1)
	local tc = g:GetFirst()
	if tc:GetType() == TYPE_SPELL then
		Duel.DisableShuffleCheck()
		Duel.SendtoGrave(g, REASON_EFFECT)
		local ae = tc:GetActivateEffect()
		if tc:IsLocation(LOCATION_GRAVE) and ae then
			local e1 = Effect.CreateEffect(tc)
			e1:SetDescription(ae:GetDescription())
			e1:SetType(EFFECT_TYPE_IGNITION)
			e1:SetCountLimit(1)
			e1:SetRange(LOCATION_GRAVE)
			e1:SetReset(RESET_EVENT + 0x2fe0000 + RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
			e1:SetCondition(s.spellcon)
			e1:SetTarget(s.spelltg)
			e1:SetOperation(s.spellop)
			tc:RegisterEffect(e1)
		end
	else
		Duel.MoveSequence(tc, SEQ_DECKBOTTOM)
	end
end
function s.spellcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():GetTurnID() ~= Duel.GetTurnCount()
end
function s.spelltg(e, tp, eg, ep, ev, re, r, rp, chk)
	local ae = e:GetHandler():GetActivateEffect()
	local ftg = ae:GetTarget()
	if chk == 0 then
		e:SetCostCheck(false)
		return not ftg or ftg(e, tp, eg, ep, ev, re, r, rp, chk)
	end
	if ae:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
	else
		e:SetProperty(0)
	end
	if ftg then
		e:SetCostCheck(false)
		ftg(e, tp, eg, ep, ev, re, r, rp, chk)
	end
end
function s.spellop(e, tp, eg, ep, ev, re, r, rp)
	local ae = e:GetHandler():GetActivateEffect()
	local fop = ae:GetOperation()
	fop(e, tp, eg, ep, ev, re, r, rp)
end

