Generate a YGOPro Lua script for the following Yu-Gi-Oh card effect:
During your Main Phase, you can activate 1 "Attraction" Trap the turn it was Set. During the End Phase: You can send 1 "Attraction" Trap you control equipped to a monster to the GY, then target 1 of your "Attraction" Traps, with a different name, that is banished or in your GY; Set that card. You can only use each effect of "Amazement Precious Park" once per turn.
--アメイズメント・プレシャスパーク
--Amazement Precious Park
--Scripted by Eerie Code
local s,id=GetID()
function s.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--"Attraction" Trap cards can be activated during the turn they are set (during your Main Phase)
	local e2=Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
	e2:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
	e2:SetRange(LOCATION_FZONE)
	e2:SetTargetRange(LOCATION_SZONE,0)
	e2:SetCondition(function(e) return Duel.IsMainPhase() and Duel.IsTurnPlayer(e:GetHandlerPlayer()) end)
	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,SET_ATTRACTION))
	e2:SetDescription(aux.Stringid(id,0))
	e2:SetCountLimit(1,id)
	c:RegisterEffect(e2)
	--Set 1 "Attraction" Trap that is banished or in the GY
	local e3=Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_PHASE+PHASE_END)
	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
	e3:SetRange(LOCATION_FZONE)
	e3:SetCountLimit(1,{id,1})
	e3:SetCost(s.setcost)
	e3:SetTarget(s.settg)
	e3:SetOperation(s.setop)
	c:RegisterEffect(e3)
end
s.listed_series={SET_ATTRACTION}
function s.setcost(e,tp,eg,ep,ev,re,r,rp,chk)
	e:SetLabel(1)
	return true
end
function s.eqfilter(c,ec)
	return c:GetEquipGroup():IsContains(ec)
end
function s.setfilter(c,ec)
	return c:IsTrap() and c:IsSetCard(SET_ATTRACTION) and (c:IsFaceup() or c:IsLocation(LOCATION_GRAVE))
		and not c:IsCode(ec:GetCode()) and c:IsSSetable(true)
end
function s.cfilter(c,tp)
	return c:IsFaceup() and c:IsTrap() and c:IsSetCard(SET_ATTRACTION)
		and Duel.IsExistingMatchingCard(s.eqfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,c)
		and Duel.IsExistingTarget(s.setfilter,tp,LOCATION_GRAVE|LOCATION_REMOVED,0,1,nil,c)
end
function s.settg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return chkc:IsLocation(LOCATION_GRAVE|LOCATION_REMOVED) and chkc:IsControler(tp) and s.setfilter(chkc,e:GetLabelObject()) end
	if chk==0 then
		if e:GetLabel()~=1 then return false end
		e:SetLabel(0)
		return Duel.GetLocationCount(tp,LOCATION_SZONE)>-1 and Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_SZONE,0,1,nil,tp)
	end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
	local gc=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_SZONE,0,1,1,nil,tp):GetFirst()
	e:SetLabelObject(gc)
	Duel.SendtoGrave(gc,REASON_COST)
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET)
	local g=Duel.SelectTarget(tp,s.setfilter,tp,LOCATION_GRAVE|LOCATION_REMOVED,0,1,1,nil,gc)
	Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,g,1,0,0)
end
function s.setop(e,tp,eg,ep,ev,re,r,rp)
	local tc=Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) and tc:IsSSetable() then
		Duel.SSet(tp,tc)
	end
end