Generate a YGOPro Lua script for the following Yu-Gi-Oh card effect:
You can activate 1 of these effects, based on the Attributes in your GY; ● LIGHT: Send 1 "Blue-Eyes White Dragon", or 1 card that mentions it, from your Deck to the GY, except "Chronicle Sorceress". ● DARK: Send 1 "Dark Magician", or 1 card that mentions it, from your Deck to the GY, except "Chronicle Sorceress". You can only use this effect of "Chronicle Sorceress" once per turn.
--クロニクル・ソーサレス
--Chronicle Sorceress
--Logical Nonsense
local s,id=GetID()
function s.initial_effect(c)
	--Activate 1 of these effects, based on the Attributes in your GY
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id,0))
	e1:SetCategory(CATEGORY_TOGRAVE)
	e1:SetType(EFFECT_TYPE_IGNITION)
	e1:SetRange(LOCATION_MZONE)
	e1:SetCountLimit(1,id)
	e1:SetTarget(s.tgtg)
	e1:SetOperation(s.tgop)
	c:RegisterEffect(e1)
end
s.listed_names={CARD_BLUEEYES_W_DRAGON,CARD_DARK_MAGICIAN,id}
function s.tgfilter(c,code)
	return (c:IsCode(code) or c:ListsCode(code)) and not c:IsCode(id) and c:IsAbleToGrave()
end
function s.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
	local b1=Duel.IsExistingMatchingCard(Card.IsAttribute,tp,LOCATION_GRAVE,0,1,nil,ATTRIBUTE_LIGHT)
		and Duel.IsExistingMatchingCard(s.tgfilter,tp,LOCATION_DECK,0,1,nil,CARD_BLUEEYES_W_DRAGON)
	local b2=Duel.IsExistingMatchingCard(Card.IsAttribute,tp,LOCATION_GRAVE,0,1,nil,ATTRIBUTE_DARK)
		and Duel.IsExistingMatchingCard(s.tgfilter,tp,LOCATION_DECK,0,1,nil,CARD_DARK_MAGICIAN)
	if chk==0 then return b1 or b2 end
	local op=Duel.SelectEffect(tp,
		{b1,aux.Stringid(id,1)},
		{b2,aux.Stringid(id,2)})
	e:SetLabel(op)
	Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function s.tgop(e,tp,eg,ep,ev,re,r,rp)
	local code=e:GetLabel()==1 and CARD_BLUEEYES_W_DRAGON or CARD_DARK_MAGICIAN
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
	local g=Duel.SelectMatchingCard(tp,s.tgfilter,tp,LOCATION_DECK,0,1,1,nil,code)
	if #g>0 then
		Duel.SendtoGrave(g,REASON_EFFECT)
	end
end