Here is the effect:
If this card is Rank 12 and has at least 12 or more Xyz Materials to attach to it, you can Tribute this card to Special Summon "xxx” from your Extra Deck ignoring summoning conditions, then attach this card from your Graveyard to “xxx” as Xyz Material.
Here is what I have:
local e9=Effect.CreateEffect(c)
e9:SetDescription(aux.Stringid(90516151,2))
e9:SetCategory(CATEGORY_SPECIAL_SUMMON)
e9:SetType(EFFECT_TYPE_IGNITION)
e9:SetRange(LOCATION_MZONE)
e9:SetCost(c90516151.spcost)
e9:SetTarget(c90516151.sptg)
e9:SetOperation(c90516151.spop)
c:RegisterEffect(e9)
function c90516151.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsReleasable() end
Duel.Release(e:GetHandler(),REASON_COST)
end
function c90516151.filter(c,e,tp)
return c:IsCode(90516152) and c:IsCanBeSpecialSummoned(e,0,tp,true,false)
end
function c90516151.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1
and Duel.IsExistingMatchingCard(c90516151.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA)
end
function c90516151.spop(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,c90516151.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc and Duel.SpecialSummonStep(tc,0,tp,tp,true,false,POS_FACEUP) then
local cg=Group.FromCards(c)
tc:SetMaterial(cg)
Duel.Overlay(tc,cg)
Duel.SpecialSummon(tc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP)
tc:CompleteProcedure()
else
local cg=Duel.GetFieldGroup(tp,LOCATION_EXTRA,0)
if cg:IsExists(Card.IsFacedown,1,nil) and Duel.IsPlayerCanSpecialSummon(tp) then
Duel.ConfirmCards(1-tp,cg)
end
end
end
The Problem is that it doesn't Attach from the Grave. Also the reason that the conditions is not here is because I was just testing the tribute attach part of the card.