Generate a YGOPro Lua script for the following Yu-Gi-Oh card effect:
If you control a card with an effect that requires a die roll: You can Tribute 1 monster; Special Summon 1 monster with a monster effect that requires a die roll from your hand or Deck. * The above text is unofficial and describes the card's functionality in the OCG.
--ディメンジョン・ダイス
--Dimension Dice
--scripted by Naim
local s,id=GetID()
function s.initial_effect(c)
	--Tribute 1 monster and Special Summon 1 monster from the hand or deck with a die roll effect
	local e1=Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetCondition(s.condition)
	e1:SetCost(s.cost)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
end
function s.dicefilter(c)
	return c.roll_dice and c:IsFaceup()
end
function s.condition(e,tp,eg,ep,ev,re,r,rp)
	return Duel.IsExistingMatchingCard(s.dicefilter,tp,LOCATION_ONFIELD,0,1,nil)
end
function s.spcfilter(c,tp)
	return Duel.GetMZoneCount(tp,c)>0
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.CheckReleaseGroupCost(tp,s.spcfilter,1,false,nil,nil,tp) end
	local sg=Duel.SelectReleaseGroupCost(tp,s.spcfilter,1,1,false,nil,nil,tp)
	Duel.Release(sg,REASON_COST)
end
function s.spfilter(c,e,tp)
	return c.roll_dice and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
		and c:IsType(TYPE_EFFECT)
	--pending rulings, cannot SS Normal Pendulums with a die roll Pendulum Effect
end
function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_HAND|LOCATION_DECK,0,1,nil,e,tp) end
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND|LOCATION_DECK)
end
function s.activate(e,tp,eg,ep,ev,re,r,rp)
	if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_HAND|LOCATION_DECK,0,1,1,nil,e,tp)
	if #g>0 then
		Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
	end
end