Producer

14 - Sort by Market Value

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.

Name Size MD5
ProducerM.zip 114.5 KiB 6afe0ef74c8a...
User When Change
DerSchreiner Mar 07, 2010 at 18:12 UTC

Added attachment ProducerM.zip

DerSchreiner Mar 07, 2010 at 17:50 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 3 comments
  • Avatar of DerSchreiner DerSchreiner Mar 07, 2010 at 18:51 UTC - 0 likes

    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

  • Avatar of DerSchreiner DerSchreiner Mar 07, 2010 at 18:47 UTC - 0 likes

    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

    Last edited Mar 07, 2010 by DerSchreiner
  • Avatar of DerSchreiner DerSchreiner Mar 07, 2010 at 18:14 UTC - 0 likes

    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
    Last edited Mar 07, 2010 by DerSchreiner
  • 3 comments

Facts

Last updated
Mar 07, 2010
Reported
Mar 07, 2010
Status
New - Issue has not had initial review yet.
Type
Enhancement - A change which is intended to better the project in some way
Priority
Medium - Normal priority.
Votes
0

Reported by

Possible assignees