Created
January 4, 2015 07:10
-
-
Save anantn/86e66f2c464ce5e5c751 to your computer and use it in GitHub Desktop.
Auctionator Plugin for Skillet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Skillet: A tradeskill window replacement. | |
Copyright (c) 2007 Robert Clark <[email protected]> | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program. If not, see <http://www.gnu.org/licenses/>. | |
]]-- | |
Skillet.AuctionatorPlugin = {} | |
local oldExtra = nil | |
local plugin = Skillet.AuctionatorPlugin | |
local function format_price(id) | |
local price = Atr_GetAuctionBuyout(id) | |
if not price then | |
return nil | |
end | |
return "|r " .. GetCoinTextureString(price) | |
end | |
local function sort_recipe_by_ah_price(tradeskill, a, b) | |
while a.subGroup and #a.subGroup.entries>0 do | |
a = a.subGroup.entries[1] | |
end | |
while b.subGroup and #b.subGroup.entries>0 do | |
b = b.subGroup.entries[1] | |
end | |
local left_r = Skillet:GetRecipe(a.recipeID) | |
local right_r = Skillet:GetRecipe(b.recipeID) | |
local left = Atr_GetAuctionBuyout(left_r.itemID) | |
local right = Atr_GetAuctionBuyout(right_r.itemID) | |
if not left then left = 0 end | |
if not right then right = 0 end | |
return left > right | |
end | |
function plugin.OnInitialize() | |
if Atr_GetAuctionBuyout then | |
local old_count = Skillet.CustomizeCountsColumn | |
Skillet.CustomizeCountsColumn = function(obj, recipe, countText) | |
old_count(obj, recipe, countText) | |
countText:SetWidth(countText:GetWidth() + 155) | |
countText:SetText((countText:GetText() or "") .. " " .. (format_price(recipe.itemID) or "")) | |
end | |
Skillet:AddRecipeSorter("AH Price", sort_recipe_by_ah_price) | |
end | |
end | |
function plugin.GetExtraText(skill, recipe) | |
local extra_text, label | |
if Atr_GetAuctionBuyout then | |
extra_text = format_price(recipe.itemID) | |
if extra_text ~= nil then | |
extra_text = extra_text .. " " | |
end | |
end | |
label = "AH Price: " | |
return label, extra_text | |
end | |
Skillet:RegisterDisplayDetailPlugin("AuctionatorPlugin") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment