Compare commits

...

3 Commits

Author SHA1 Message Date
Robin Hüskes 0ebf6dc71f Add pref for SellGrey 2022-12-03 15:08:41 +01:00
Robin Hüskes b5c389c61f Add strings for SellGrey 2022-12-03 15:08:11 +01:00
Robin Hüskes b581b96d72 Add SellGrey functionality
Switch from MERCHANT_SHOW to MANAGER_FRAME
2022-12-03 15:07:48 +01:00
4 changed files with 86 additions and 7 deletions

View File

@ -5,7 +5,11 @@ local events = child['events']
local db, player
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
LibStub("zzHelper"):Embed(child)
child['statusItem'] = {}
child['statusItem'] = {}
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
local GetContainerItemLink = GetContainerItemLink
local GetContainerItemInfo = GetContainerItemInfo
local function prepareDB()
db = addon['db']['profile'][childName]
child['db'] = db
@ -28,7 +32,68 @@ local function getGBLimit()
end
return amount
end
function events:MERCHANT_SHOW()
local function itemInfo(id)
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(id)
if(itemName) then
return {
['itemId'] = id,
['itemName'] = itemName,
['itemLink'] = itemLink,
['itemRarity'] = itemRarity,
['itemLevel'] = itemLevel,
['itemMinLevel'] = itemMinLevel,
['itemType'] = itemType,
['itemSubType'] = itemSubType,
['itemStackCount'] = itemStackCount,
['itemEquipLoc'] = itemEquipLoc,
['itemTexture'] = itemTexture,
['itemSellPrice'] = itemSellPrice
}
end
end
local function CheckGrey(dont)
local info,i = {},{}
local a = 0
local numberOfSlots,link,id
local earnedMoney = 0
while(a<=NUM_BAG_SLOTS) do
numberOfSlots = C_Container.GetContainerNumSlots(a)
local b = 1
while(b<=numberOfSlots) do
local item = ItemLocation:CreateFromBagAndSlot(a, b)
if(item:IsValid()) then
-- link = C_Container.GetContainerItemLink(a, b)
id = C_Item.GetItemID(item)
info = itemInfo(id)
if(info) then
if(info['itemRarity'] == 0) then
if(info['itemSellPrice'] and info['itemSellPrice'] > 0) then
local cinfo = C_Container.GetContainerItemInfo(a, b)
if(cinfo['stackCount']) then
if(not dont) then
print(L['solditem'](C_Item.GetItemLink(item), info['itemSellPrice']))
end
earnedMoney = earnedMoney + info['itemSellPrice'] * cinfo['stackCount']
C_Container.PickupContainerItem(a, b)
PickupMerchantItem()
end
end
end
end
end
b = b + 1
end
a = a + 1
end
if(earnedMoney > 0 and not dont) then
print(L['earnedmoney'](earnedMoney))
end
if(earnedMoney>0 and not dont) then
C_Timer.After(1,function() CheckGrey(true) end)
end
end
local function MERCHANT_SHOW()
if(CanMerchantRepair()) then
local m = GetMoney()
local r = GetRepairAllCost()
@ -60,6 +125,9 @@ function events:MERCHANT_SHOW()
db['repairstats'][player] = db['repairstats'][player] + r
end
end
if(db['sellgrey']) then
CheckGrey()
end
end
function child:pickColor(v)
local col = 'ffffff'
@ -102,6 +170,9 @@ function events:UPDATE_INVENTORY_DURABILITY()
end
events.UPDATE_INVENTORY_ALERTS = events.UPDATE_INVENTORY_DURABILITY
events.UNIT_INVENTORY_CHANGED = events.UPDATE_INVENTORY_DURABILITY
local function MFOpen(...)
MERCHANT_SHOW()
end
child['specs'] = {
['name'] = childName,
['sv'] = true,
@ -122,5 +193,6 @@ function events:PLAYER_ENTERING_WORLD(event)
child:UnregisterEvent('PLAYER_ENTERING_WORLD')
player = format("%s-%s", UnitFullName("player"))
events.UPDATE_INVENTORY_DURABILITY()
child:RegisterOpen(5, MFOpen)
end
child:NewAddOn(...)

View File

@ -40,10 +40,13 @@ if L then
L['Allow Guildbank Repair'] = "Repariere aus Gildenbank"
L['Money low'] = "Nicht genug Geld f\195\188r Reparatur!"
L['HINT3'] = "|c0000ff00Shift-Linksklick|r |c00ffffffschaltet Minimapicon an/aus|r"
L["SellGrey"] = "Verkaufe graue Gegenst\195\164nde"
L['solditem'] = function(link, price) return format("%s verkauft f\195\188r %s", link, child:MoneyString(price, true)) end
L['earnedmoney'] = function(earnedMoney) return format ("%s verdient.", child:MoneyString(earnedMoney, true)) end
end
-- <20> \195\182 <20> \195\159
-- <20> \195\188 <20> \195\164
-- <20> \195\132
-- <20> \195\182
-- <20> \195\156
-- <20> \195\182 <20> \195\159
-- <20> \195\188 <20> \195\164
-- <20> \195\132
-- <20> \195\182
-- <20> \195\156

View File

@ -40,4 +40,7 @@ if L then
L['Allow Guildbank Repair'] = true
L['Money low'] = "No fund for repair!"
L['HINT3'] = "|c0000ff00Shift-Leftclick|r |c00fffffftoggles minimap icon|r"
L["SellGrey"] = "Sell grey items"
L['solditem'] = function(link, price) return format("%s sold for %s", link, child:MoneyString(price, true)) end
L['earnedmoney'] = function(earnedMoney) return format ("Earned %s.", child:MoneyString(earnedMoney, true)) end
end

View File

@ -12,6 +12,7 @@ local init = {
local main = options['args'][childName]
-- print("setup prefs", childName)
config:AddConfigEntry(main, "autorepair", "toggle", L['Autorepair'], nil, 1)
config:AddConfigEntry(main, "sellgrey", "toggle", L['SellGrey'], nil, 1)
config:AddConfigEntry(main, "showlowest", "toggle", L['Show lowest'], L['Show durability of your lowest item only'], 1)
config:AddConfigEntry(main, "listall", "toggle", L['Show all slots'], L['Show all slots in the tooltip instead of damaged only'], 1)
config:AddConfigEntry(main, "guildbankrepair", "toggle", L['Allow Guildbank Repair'], nil, 1)