Sort by Market Value #14


  • New
  • Enhancment
Open
  • Forge_User_19273083 created this issue Mar 7, 2010

    Sorting by market value would make a lot of sense if you have Auctioneer or something similar installed. I tried to patch that, but couldn't find the right place. I'll try again though :-)

    For the implementation it would be best if the market value for items was fetched only once, or at least only once for each opening a particular subset.

  • Forge_User_19273083 added the tags New Enhancment Mar 7, 2010
  • Forge_User_19273083 added an attachment ProducerM.zip Mar 7, 2010

    ProducerM.zip

  • Forge_User_19273083 posted a comment Mar 7, 2010

    Works now (not perfect, but ok):

    1. moved GetPriceData to Producer.lua
    2. added a sortMarketValue function to CraftFrame
    3. on item list load, add a “marketvalue” to each item
    4. added some options, a bit of localization

    Edited Mar 7, 2010
  • Forge_User_19273083 posted a comment Mar 7, 2010

    Some modifications to try and not stumble over Research trade skills.
    ----------------------------------------------
    local function ScanTrade()
        local num = GetNumTradeSkills()
        for i = 1,num do
            local name, kind, _, _, cast = GetTradeSkillInfo( i)
            if kind ~= 'header' and name then
                local trade = {}
                trade.difficulty = DIFFICULTY[kind]
                trade.index i
                trade.name   = name
                trade.cast  = cast
                trade.link  = GetTradeSkillItemLink( i)
                trade.recipe = GetTradeSkillRecipeLink( i)
                
                if (not trade.cast and (not string.find(name, "Research")) then
                    local sell, buy, buyout = Producer:GetPriceData( trade.link
                    if buyout == nil then
                        trade.marketvalue = 0
                    else
                        trade.marketvalue = buyout
                    end
                else
                    trade.marketvalue = 0
                end            
                
                local minMade, maxMade = GetTradeSkillNumMade( i)
                trade.min = minMade or 1
                trade.max = maxMade or 1
                if not trade.link then
                    Producer:Debug( 'missing link:', name)
                end
                if not trade.recipe then
                    Producer:Debug( 'missing recipe:', name)
                end
                if trade.link == trade.recipe then
                    Producer:Debug( 'link == recipe:', GetLinkID( trade.link name)
                end
                trade.reagents = {}
                local numReags = GetTradeSkillNumReagents( i)
                for j = 1,numReags do
                    local rName, rIcon, rNeed = GetTradeSkillReagentInfo( i, j)
                    if rName and rIcon then
                        local rLink = GetTradeSkillReagentItemLink( i, j)
                        table.insert( trade.reagents { name = rName, link = rLink, need = rNeed }) -- icon = rIcon,
                    end
                end
                trade.set  = L.Unsorted
                trade.skill = 450
                data.profession[name] = trade
            end
        end
    end


    Edited Mar 7, 2010
  • Forge_User_19273083 posted a comment Mar 7, 2010

    typo...
    -------------------------------------
    local function sortMarketValue( a, b)
        if not a then return false end
        if not b then return true end
        if a.marketvalue == b.marketvalue then
            return a.name < b.name
        end
        return a.marketvalue > b.marketvalue
    end


To post a comment, please login or register a new account.