--[[ BottomScanner - An AddOn for WoW to alert you to good purchases as they appear on the AH Version: 5.0.PRE.2995 (BillyGoat) Revision: $Id: FilterItemType.lua 2311 2007-10-09 15:10:00Z mentalpower $ URL: http://auctioneeraddon.com/dl/BottomScanner/ Copyright (c) 2006, Norganna This is a module for BtmScan to filter an item for purchase. If you wish to make your own module, do the following: - Make a copy of the supplied "EvalFilterTemplate.lua" file. - Rename your copy to a name of your choosing. - Edit your copy to do your own valuations of the item. (search for the "TODO" sections in the file) - Insert your new file's name into the "BtmScan.toc" file. - Optionally, put it up on the wiki at: http://norganna.org/wiki/BottomScanner/Filters License: 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 2 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(see GPL.txt); if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Note: This AddOn's source code is specifically designed to work with World of Warcraft's interpreted AddOn system. You have an implicit licence to use this AddOn with these facilities since that is its designated purpose as per: http://www.fsf.org/licensing/licenses/gpl-faq.html#InterpreterIncompat ]] local libName = "Hotcakes" local lcName = libName:lower() local lib = { name = lcName, propername = libName } table.insert(BtmScan.filters, lcName) local define = BtmScan.Settings.SetDefault local get = BtmScan.Settings.GetSetting local set = BtmScan.Settings.SetSetting local translate = BtmScan.Locales.Translate BtmScan.filters[lcName] = lib function lib:filterItem(item, evaluationModule) local price = 0 local filterModule=false -- If we're not enabled, scadaddle! if (not get(lcName..".enable")) then return end if ( get(lcName..".filter."..evaluationModule)==false) then return end -- If this item is grey, forget about it. if (item.qual == 0) then return end local _, _, itemRarity, itemLevel, _, itemType = GetItemInfo(item.id) itemId = item.id if (not itemLevel) then return end if (not itemType) then return end local minLevel=0 local success = 0 local failed = 0 if BeanCounter and BeanCounter.Private.playerData then if BeanCounter.Private.playerData["completedAuctions"][tostring(itemId)] then success = #BeanCounter.Private.playerData["completedAuctions"][tostring(itemId)] end if BeanCounter.Private.playerData["failedAuctions"][tostring(itemId)] then failed = #BeanCounter.Private.playerData["failedAuctions"][tostring(itemId)] end end s = success f = failed target_ratio = get(lcName..".target_ratio") verbose = get(lcName..".verbose") try_new_things = get(lcName..".try_new_things") min_scan_filter = get(lcName..".min_scan_filter") actual_ratio = 0 if (s+f) == 0 then if try_new_things then actual_ratio = 1 else actual_ratio = 0 end else if (s+f) < min_scan_filter then actual_ratio = 1 else actual_ratio = s/(s+f) end end local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount = GetItemInfo(itemId); if (actual_ratio < target_ratio) then if verbose then BtmScan.Print("Hotcakes: Filtered: "..tostring(sLink)..". "..s.." successes, "..f.." failed. Ratio: "..tostring(actual_ratio).." did not meet minimum ratio of "..tostring(target_ratio)) end -- module-filter -> filterModule=true end return filterModule end define(lcName..'.enable', false) define(lcName..'.target_ratio', 0.5) define(lcName..'.verbose', false) define(lcName..'.try_new_things', true) define(lcName..'.min_scan_filter', 1) function lib:setup(gui) id = gui:AddTab(libName) gui:AddControl(id, "Subhead", 0, libName.." Settings") gui:AddControl(id, "Checkbox", 0, 1, lcName..".enable", "Enable basic-filtering") for pos, name in ipairs(BtmScan.evaluators) do if (name=="vendor") then define(lcName..".filter."..name, false) else define(lcName..".filter."..name, true) end gui:AddControl(id, "Checkbox", 0, 1, lcName..".filter."..name, " activate Filter for module:"..name) end gui:AddControl(id, "WideSlider", 0, 1, lcName..".target_ratio", 0, 1, 0.05, "Minimum Success/Total Ratio: %s") gui:AddControl(id, "Checkbox", 0, 1, lcName..".try_new_things", "If there's no BeanCounter data for an item, don't filter it.") gui:AddControl(id, "WideSlider", 0, 1, lcName..".min_scan_filter", 0, 100, 1, "Enable filtering only if %s or more data points.") gui:AddControl(id, "Checkbox", 0, 1, lcName..".verbose", "Verbose mode. Report what's filtered and why.") end