Spellbook
Send to the GY either 1 Spellcaster monster you control, or 1 other "Spellbook" card from your hand or face-up field, except "Spellbook of Knowledge", and if you do, draw 2 cards. You can only activate 1 "Spellbook of Knowledge" per turn.
local SETCARD_ID_0 = 0x106e --Spellbook

local SETCARD_ID_0 = 0x106e --Spellbook
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_TOGRAVE + CATEGORY_DRAW)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.filter(c)
	return (((c:IsFaceup() or c:IsLocation(LOCATION_HAND)) and c:IsSetCard(SETCARD_ID_0)) or (c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsRace(RACE_SPELLCASTER)))
		and not c:IsCode(id)
		and c:IsAbleToGrave()
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsPlayerCanDraw(tp, 2) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, e:GetHandler())
	end
	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_HAND + LOCATION_ONFIELD)
	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 2)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, e:GetHandler())
	local tc = g:GetFirst()
	if tc and Duel.SendtoGrave(tc, REASON_EFFECT) > 0 and tc:IsLocation(LOCATION_GRAVE) then
		Duel.Draw(tp, 2, REASON_EFFECT)
	end
end


Spellbook
Send to the GY either 1 Spellcaster monster you control, or 1 other "Spellbook" card from your hand or face-up field, except "Spellbook of Knowledge", and if you do, draw 2 cards. You can only activate 1 "Spellbook of Knowledge" per turn.
-- Spellbook
local SETCARD_ID_0 = 0x106e --Spellbook
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_TOGRAVE + CATEGORY_DRAW)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.filter(c)
	return (((c:IsFaceup() or c:IsLocation(LOCATION_HAND)) and c:IsSetCard(SETCARD_ID_0)) or (c:IsFaceup() and c:IsLocation(LOCATION_MZONE) and c:IsRace(RACE_SPELLCASTER)))
		and not c:IsCode(id)
		and c:IsAbleToGrave()
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsPlayerCanDraw(tp, 2) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, e:GetHandler())
	end
	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_HAND + LOCATION_ONFIELD)
	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 2)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, e:GetHandler())
	local tc = g:GetFirst()
	if tc and Duel.SendtoGrave(tc, REASON_EFFECT) > 0 and tc:IsLocation(LOCATION_GRAVE) then
		Duel.Draw(tp, 2, REASON_EFFECT)
	end
end

