View Single Post
Old 09-25-10, 06:51 AM   #19
SinusPi
A Deviate Faerie Dragon
Join Date: Nov 2008
Posts: 10
But there's also a :Show() at the start of the function, it works as expected

I didn't use a standalone script, I just added a "logging" function to your rIMV_setModel function and skipped through pages. I'm lazy. ;P I edited it out already, sorry ^^;

And meanwhile, I also added full filtering support, though it's slash-command based. Oh, and the data I gathered must be loaded under a 'IMVtags' variable for this to work.

Code:
  local filtered
Code:
  local function rIMV_setModel(self,id)
  
    self:Show()  --sinus

    self:ClearModel()
    --m:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") --in case setdisplayinfo fails 
    local dispinfo = filtered and (filtered[id] or 0) or id
    self:SetDisplayInfo(dispinfo)

    if self:GetModel()==self then self:Hide() end  -- sinus: hide missing models

    self.id = dispinfo
    self.p:SetText(dispinfo)

  end
Code:
SLASH_IMV1 = "/imv"
function SlashCmdList.IMV(text)
    tag = text:trim()
    if IMVtags[tag] then
        filtered={}
        for id=1,40000 do if IMVtags[tag][id] then tinsert(filtered,id) end end
        print("Filtering by tag '"..tag.."', result: "..#filtered)
    elseif tag:find("%*") then
        tag="^"..tag:replace("*",".*").."$"
        filtered={}
        local unpruned={}
        for t,data in pairs(IMVtags) do
            if t:find(tag) then
                for id,t in pairs(data) do unpruned[id]=true end
            end
        end
        for id=1,40000 do if unpruned[id] then tinsert(filtered,id) end end
        print("Filtering by pattern '"..tag.."', result: "..#filtered)
    elseif tag=="?" then
        local s=""
        for tag,n in pairs(IMVtags) do if s~="" then s=s..", " end  s=s..tag end
        print("Tags: "..s)
        return
    else
        filtered=nil
        print("Filtering off (use '?' to list tags)")
    end

    if tag=="" or (filtered and #filtered>0) then
        rIMV_HolderFrame:Show()
        rIMV_createAllModels(rIMV_HolderFrame)
        rIMV_HolderFrame:EnableMouse(true)
        rIMV_HolderFrame.ag1:Play()
    end
end
This enables commands such as:
/imv (no filtering)
/imv creature (one tag)
/imv spell* (spells,spellportals etc.)
/imv ? (lists HUGE tags list)
SinusPi is offline   Reply With Quote