Initial push
This commit is contained in:
commit
9fb97eb511
|
@ -0,0 +1,3 @@
|
|||
[submodule "Common"]
|
||||
path = Common
|
||||
url = https://git.grml.de/rilgamon/Common.git
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed
|
|
@ -0,0 +1,367 @@
|
|||
local name, addon = ...
|
||||
local parentName = addon['parentName'] or "BrokerPack"
|
||||
local childName = "zz_AltMail"
|
||||
local defaults = {
|
||||
}
|
||||
|
||||
local options = {
|
||||
}
|
||||
|
||||
local db
|
||||
local realm = GetRealmName()
|
||||
local function GetUName()
|
||||
local name = UnitName("player")
|
||||
return name.."-"..realm
|
||||
end
|
||||
addon.GetUName = GetUName
|
||||
local itemTypes = {}
|
||||
local itemSubtypes = {}
|
||||
local function populate()
|
||||
--[[ for k, v in pairs(_G) do
|
||||
if strsub(k, 1, 12) == 'NUM_LE_ITEM_' then
|
||||
print(k, v)
|
||||
end
|
||||
end]]
|
||||
local types = {}
|
||||
for i = 1, NUM_LE_ITEM_CLASSS do
|
||||
local n = 1
|
||||
local subclassName = ''
|
||||
local className = GetItemClassInfo(i - 1)
|
||||
if(className) then
|
||||
itemTypes[className] = i
|
||||
itemSubtypes[className] = itemSubtypes[className] or {}
|
||||
types[i] = {
|
||||
['name'] = className,
|
||||
['subtypes'] = {}
|
||||
}
|
||||
while(subclassName) do
|
||||
subclassName = GetItemSubClassInfo(i - 1, n - 1)
|
||||
if(subclassName and strlen(subclassName) > 0) then
|
||||
itemSubtypes[className][subclassName] = n
|
||||
types[i]['subtypes'][n] = subclassName
|
||||
n = n + 1
|
||||
end
|
||||
if(subclassName and strlen(subclassName) < 1) then
|
||||
subclassName = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return types
|
||||
end
|
||||
local function IsSoulbound(bag, slot)
|
||||
local item = ItemLocation:CreateFromBagAndSlot(bag, slot)
|
||||
if(item) then
|
||||
return C_Item.IsBound(item)
|
||||
end
|
||||
end
|
||||
local function GetDestination(bag,slot)
|
||||
local item = ItemLocation:CreateFromBagAndSlot(bag, slot)
|
||||
if(C_Item.IsBound(item)) then return end
|
||||
local quality = C_Item.GetItemQuality(item)
|
||||
local itemLink = C_Item.GetItemLink(item)
|
||||
-- local texture, itemCount, locked, quality, readable, lootable, itemLink, isFiltered, noValue, itemID = GetContainerItemInfo(bag, slot)
|
||||
if(itemLink) then
|
||||
local typ = string.match(itemLink, "^(.-):")
|
||||
if(typ~="battlepet" and quality<5 and quality>0) then
|
||||
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice, itemClassID, itemSubClassID, bindType, expacID, itemSetID, isCraftingReagent = GetItemInfo(itemLink)
|
||||
if(itemName) then
|
||||
-- itemType = LibBabbleDBR[itemType]
|
||||
-- itemSubType = LibBabbleDBR[itemSubType]
|
||||
-- print(itemType.."-"..itemSubType.."-"..itemLink)
|
||||
if(db['itemdb'][realm] and db['itemdb'][realm][itemClassID] and db['itemdb'][realm][itemClassID][itemSubClassID]) then
|
||||
local tmp = db['itemdb'][realm][itemClassID][itemSubClassID]
|
||||
sort(tmp, function(a,b)
|
||||
return (a['order'] or 0) < (b['order'] or 0)
|
||||
end)
|
||||
for dest,destInfo in pairs(tmp) do
|
||||
if(type(destInfo) == 'table') then
|
||||
local doSkip = false
|
||||
-- print(dest,destInfo['skip'])
|
||||
for _,skip in ipairs(destInfo['skip']) do
|
||||
if(skip == GetUName()) then doSkip=true end
|
||||
end
|
||||
if(not doSkip) then
|
||||
return dest
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function GetNumMailboxItems()
|
||||
local count = 0
|
||||
for i = 1, ATTACHMENTS_MAX_SEND do
|
||||
local name, texture, count, quality = GetInboxItem(i)
|
||||
if(name) then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
local function sout(target)
|
||||
SendMail(target, "Post",nil)
|
||||
SELECTED_CHAT_FRAME:AddMessage("Sending "..target)
|
||||
end
|
||||
local sf_new = function()
|
||||
if(not SendMailFrame:IsVisible()) then return end
|
||||
local a,b = 0,0
|
||||
local tab = {}
|
||||
while(a<=NUM_BAG_SLOTS) do
|
||||
b = 1
|
||||
while(b<=GetContainerNumSlots(a)) do
|
||||
local _, _, _, _, _, _, itemLink = GetContainerItemInfo(a, b)
|
||||
if(itemLink) then
|
||||
local itemName, itemLink, _, _, _, itemType, itemSubType, _, _, _, _, classID, subclassID, _, _, _, _ = GetItemInfo(itemLink)
|
||||
if(classID) then
|
||||
local it = db['itemtypes'][classID + 1]['name']
|
||||
if(subclassID and it) then
|
||||
itemType = it
|
||||
local ist = db['itemtypes'][classID + 1]['subtypes'][subclassID + 1]
|
||||
if(ist) then
|
||||
itemSubType = ist
|
||||
tab[classID] = tab[classID] or {}
|
||||
tab[classID][subclassID] = tab[classID][subclassID] or {}
|
||||
tab[classID][subclassID][#tab[classID][subclassID] + 1] = {
|
||||
['bag'] = a,
|
||||
['slot'] = b,
|
||||
}
|
||||
else
|
||||
print("no itemsubtype for "..itemName)
|
||||
end
|
||||
else
|
||||
print("no itemtype for "..itemName)
|
||||
end
|
||||
end
|
||||
end
|
||||
b = b + 1
|
||||
end
|
||||
a = a + 1
|
||||
end
|
||||
local mailout = {}
|
||||
db['itemdb'][realm] = db['itemdb'][realm] or {}
|
||||
local realmdb = db['itemdb'][realm]
|
||||
for t, v in pairs(tab) do
|
||||
if(t) then
|
||||
realmdb[t] = realmdb[t] or {
|
||||
['Default'] = {
|
||||
[GetUName()] = {
|
||||
['order'] = 1,
|
||||
['skip'] = {},
|
||||
}
|
||||
}
|
||||
}
|
||||
local typedb = db['itemdb'][realm][t]
|
||||
for s,d in pairs(v) do
|
||||
if(s) then
|
||||
typedb[s] = typedb[s] or CopyTable(typedb['Default'])
|
||||
local subtypedb = typedb[s]
|
||||
for g,h in pairs(d) do
|
||||
local target = GetDestination(tonumber(h['bag']),tonumber(h['slot']))
|
||||
if(target and subtypedb[target] and subtypedb[target]['active']) then
|
||||
mailout[target] = mailout[target] or {}
|
||||
mailout[target][#mailout[target] + 1] = {
|
||||
['bag'] = h['bag'],
|
||||
['slot'] = h['slot']
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
mailout[GetUName()] = nil
|
||||
for k,v in pairs(mailout) do
|
||||
local c = 0
|
||||
for a,b in pairs(v) do
|
||||
c = c + 1
|
||||
UseContainerItem(tonumber(b['bag']),tonumber(b['slot']))
|
||||
if(c >= 12) then
|
||||
break
|
||||
end
|
||||
end
|
||||
if(c > 0) then
|
||||
sout(k)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
SendMailFrame:HookScript("OnShow", function()
|
||||
C_Timer.After(0.25, sf_new)
|
||||
end)
|
||||
|
||||
local function OnEvent(self, event, arg1, ...)
|
||||
if(event == "MAIL_SEND_SUCCESS") then
|
||||
C_Timer.After(1,sf_new)
|
||||
end
|
||||
end
|
||||
local function OnText(message)
|
||||
addon:OnText(childName, message)
|
||||
end
|
||||
|
||||
local function getPref(pref)
|
||||
return db[pref[#pref]]
|
||||
end
|
||||
|
||||
local function setPref(pref,value)
|
||||
db[pref[#pref]] = value
|
||||
end
|
||||
local function getPrefI(pref)
|
||||
--[[
|
||||
print("3",pref[#pref]) -- pref name
|
||||
print("2",pref[#pref-1]) -- dest name
|
||||
print("1",pref[#pref-2]) -- subtype name
|
||||
print("0",pref[#pref-3]) -- type name
|
||||
]]
|
||||
if(pref[#pref-2] ~= 'Default') then
|
||||
-- print("D", db['itemdb'][realm][itemTypes[pref[#pref-3]] - 1][itemSubtypes[pref[#pref-3]][pref[#pref-2]] - 1])
|
||||
return db['itemdb'][realm][itemTypes[pref[#pref-3]] - 1][itemSubtypes[pref[#pref-3]][pref[#pref-2]] - 1][pref[#pref-1]][pref[#pref]]
|
||||
else
|
||||
return db['itemdb'][realm][itemTypes[pref[#pref-3]] - 1]['Default'][pref[#pref-1]][pref[#pref]]
|
||||
end
|
||||
end
|
||||
local function setPrefI(pref,value)
|
||||
if(pref[#pref-2] ~= 'Default') then
|
||||
db['itemdb'][realm][itemTypes[pref[#pref-3]] - 1][itemSubtypes[pref[#pref-3]][pref[#pref-2]] - 1][pref[#pref-1]][pref[#pref]] = value
|
||||
else
|
||||
db['itemdb'][realm][itemTypes[pref[#pref-3]] - 1]['Default'][pref[#pref-1]][pref[#pref]] = value
|
||||
end
|
||||
end
|
||||
local function getPrefDest(pref)
|
||||
--[[print("3",pref[#pref]) -- pref name
|
||||
print("2",pref[#pref-1]) -- subtype name
|
||||
print("1",pref[#pref-2]) -- type name]]
|
||||
local t = itemTypes[pref[#pref-2]] - 1
|
||||
local s = pref[#pref-1]=='Default' and 'Default' or itemSubtypes[pref[#pref-2]][pref[#pref-1]] - 1
|
||||
if(t and s) then
|
||||
for k, v in pairs(db['itemdb'][realm][t][s]) do
|
||||
if(type(v) == 'table') then
|
||||
return k
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function setPrefDest(pref, value)
|
||||
local old = getPrefDest(pref)
|
||||
--print(old, ">",value)
|
||||
--[[print("3",pref[#pref]) -- pref name
|
||||
print("2",pref[#pref-1]) -- subtype name
|
||||
print("1",pref[#pref-2]) -- type name]]
|
||||
local t = itemTypes[pref[#pref-2]] - 1
|
||||
local s = pref[#pref-1]=='Default' and 'Default' or itemSubtypes[pref[#pref-2]][pref[#pref-1]] - 1
|
||||
db['itemdb'][realm][t][s][value] = db['itemdb'][realm][t][s][old]
|
||||
db['itemdb'][realm][t][s][old] = nil
|
||||
addon:updatePrefs()
|
||||
end
|
||||
local function buildSelectAll()
|
||||
local sel = {}
|
||||
local n,m,_
|
||||
if(addon['db']['sv']['profileKeys']) then
|
||||
for k,v in pairs(addon['db']['sv']['profileKeys']) do
|
||||
n,_,m = strsplit(' ',k,3)
|
||||
sel[format("%s-%s",n,m)] = format("%s-%s",n,m)
|
||||
end
|
||||
end
|
||||
return sel
|
||||
end
|
||||
function addon:updatePrefs()
|
||||
db['itemdb'] = db['itemdb'] or {}
|
||||
db['itemdb'][realm] = db['itemdb'][realm] or {}
|
||||
local itemdb = db['itemdb'][realm]
|
||||
db['itemtypes'] = populate()
|
||||
local a,b = 0,0
|
||||
local curName = GetUName()
|
||||
while(a<=NUM_BAG_SLOTS) do
|
||||
b = 1
|
||||
while(b<=GetContainerNumSlots(a)) do
|
||||
local _, _, _, _, _, _, itemLink = GetContainerItemInfo(a, b)
|
||||
if(itemLink) then
|
||||
local _, _, _, _, _, itemType, itemSubType, _, _, _, _, classID, subclassID, _, _, _, _ = GetItemInfo(itemLink)
|
||||
if(classID and subclassID) then
|
||||
|
||||
itemdb[classID] = itemdb[classID] or {
|
||||
['name'] = itemType,
|
||||
['Default'] = {
|
||||
['name'] = 'Default',
|
||||
[curName] = {
|
||||
['order'] = 1,
|
||||
['skip'] = {},
|
||||
}
|
||||
}
|
||||
}
|
||||
local classdb = itemdb[classID]
|
||||
classdb['name'] = itemType
|
||||
classdb[subclassID] = classdb[subclassID] or CopyTable(classdb['Default'])
|
||||
classdb[subclassID]['name'] = itemSubType
|
||||
end
|
||||
end
|
||||
b = b + 1
|
||||
end
|
||||
a = a + 1
|
||||
end
|
||||
local p = addon['options']['args']['Types']['args']
|
||||
for classID, v in pairs(db['itemdb'][realm]) do
|
||||
if(v['name']) then
|
||||
p[v['name']] = {
|
||||
['type'] = 'group',
|
||||
['childGroups'] = 'tree',
|
||||
['name'] = v['name'],
|
||||
['args'] = {},
|
||||
}
|
||||
for subclassID, b in pairs(v) do
|
||||
if(type(b) == 'table' and b['name']) then
|
||||
p[v['name']]['args'][b['name']]={
|
||||
['type'] = 'group',
|
||||
['name'] = b['name'],
|
||||
['get'] = getPrefI,
|
||||
['set'] = setPrefI,
|
||||
['args'] = {},
|
||||
}
|
||||
local c = p[v['name']]['args'][b['name']]['args']
|
||||
c['dest'] = {
|
||||
['name'] = "Destination",
|
||||
['type'] = "select",
|
||||
['values'] = buildSelectAll,
|
||||
['get'] = getPrefDest,
|
||||
['set'] = setPrefDest
|
||||
}
|
||||
for d,e in pairs(b) do
|
||||
if(d ~= 'name') then
|
||||
c[d] = {
|
||||
['name'] = d,
|
||||
['type'] = "group",
|
||||
['args'] = {},
|
||||
}
|
||||
local f = c[d]['args']
|
||||
f['active'] = {
|
||||
['name'] = "active",
|
||||
['type'] = "toggle",
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local function init()
|
||||
realm = GetRealmName()
|
||||
options = addon:InitConfig(childName, true, {
|
||||
['type'] = "launcher",
|
||||
}, getPref, setPref)
|
||||
db = addon['db']['profile'][childName]
|
||||
db['itemdb'] = db['itemdb'] or {}
|
||||
db['itemdb'][realm] = db['itemdb'][realm] or {}
|
||||
addon:AddConfigMenu({
|
||||
['name'] = "Types",
|
||||
['order'] = 2,
|
||||
['childGroups'] = 'tree',
|
||||
['menuGet'] = getPref,
|
||||
['menuSet'] = setPref,
|
||||
}, addon['options'])
|
||||
addon:updatePrefs()
|
||||
end
|
||||
addon:startup(name, childName, init, true, defaults)
|
||||
addon:RegisterFunc({'MAIL_SEND_SUCCESS'},"OnEvent", OnEvent)
|
|
@ -0,0 +1,6 @@
|
|||
The following license excludes the libraries (Libs) included. See the libraries directory or website.
|
||||
|
||||
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
|
||||
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
|
||||
If you use/offer this addon on another website please remove my name.
|
||||
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.
|
|
@ -0,0 +1,4 @@
|
|||
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
|
||||
<Script file="core.lua"/>
|
||||
<Script file="stock.lua"/>
|
||||
</Ui>
|
|
@ -0,0 +1,80 @@
|
|||
local addonName, addon = ...
|
||||
|
||||
local stock = CreateFrame("FRAME")
|
||||
|
||||
local keepStock = {
|
||||
["Rilgana-Tirion"] = {
|
||||
[173060] = 2000, -- Wasser
|
||||
[180732] = 2000, -- Phiole
|
||||
[180817] = 1,
|
||||
[175886] = 500 -- Pergament
|
||||
},
|
||||
["Rilgany-Tirion"] = {
|
||||
[180817] = 1,
|
||||
}
|
||||
}
|
||||
function stock:BAG_UPDATE_DELAYED()
|
||||
if(not MerchantFrame or not MerchantFrame:IsVisible()) then return end
|
||||
local bag = 0
|
||||
local earnedMoney = 0
|
||||
while(bag<=NUM_BAG_SLOTS) do
|
||||
local slot = 1
|
||||
while(slot<=GetContainerNumSlots(bag)) do
|
||||
if(C_NewItems.IsNewItem(bag, slot)) then
|
||||
local item = ItemLocation:CreateFromBagAndSlot(bag, slot)
|
||||
local itemLink = C_Item.GetItemLink(item)
|
||||
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice, itemClassID, itemSubClassID, bindType, expacID, itemSetID, isCraftingReagent = GetItemInfo(itemLink)
|
||||
-- print(itemName, itemType, itemSubType, itemClassID, itemSubClassID)
|
||||
if(itemClassID ~= 7) then -- dont sell crafting reagents
|
||||
UseContainerItem(bag, slot)
|
||||
end
|
||||
end
|
||||
slot = slot + 1
|
||||
end
|
||||
bag = bag + 1
|
||||
end
|
||||
end
|
||||
function stock:MERCHANT_SHOW(event, ...)
|
||||
-- print(event, ...)
|
||||
-- self:BAG_UPDATE_DELAYED()
|
||||
if(keepStock[addon:GetUName()]) then
|
||||
for i = 1, GetMerchantNumItems() do
|
||||
local name, texture, price, quantity, numAvailable, isPurchasable, isUsable, extendedCost = GetMerchantItemInfo(i)
|
||||
if(name and isPurchasable) then
|
||||
local itemID, itemType, itemSubType, itemEquipLoc, icon, itemClassID, itemSubClassID = GetItemInfoInstant(name)
|
||||
if(keepStock[addon:GetUName()][itemID]) then
|
||||
local count = GetItemCount(itemID, true)
|
||||
if(count < keepStock[addon:GetUName()][itemID]) then
|
||||
-- print(name, itemID, quantity, numAvailable, count)
|
||||
local buy = keepStock[addon:GetUName()][itemID] - count
|
||||
if(buy > 0) then
|
||||
local maxStack = GetMerchantItemMaxStack(i)
|
||||
if(buy >= maxStack) then
|
||||
for b = 1, floor(buy / maxStack) do
|
||||
BuyMerchantItem(i, maxStack)
|
||||
buy = buy - maxStack
|
||||
end
|
||||
end
|
||||
if(buy > quantity) then
|
||||
BuyMerchantItem(i, buy)
|
||||
end
|
||||
-- print("buy", name, buy, buyStacks)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- print(i, name, isPurchasable)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
stock:RegisterEvent("MERCHANT_SHOW")
|
||||
-- stock:RegisterEvent("BAG_UPDATE_DELAYED")
|
||||
stock:SetScript("OnEvent", function(self, event, ...)
|
||||
if(type(self[event]) == 'function') then
|
||||
self[event](self, event, ...)
|
||||
else
|
||||
print("NO IDEA", event, ...)
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,9 @@
|
|||
## Interface: 90002
|
||||
## X-Repository: https://svn.grml.de/zz_AltMail
|
||||
## Title: zz AltMail
|
||||
## Notes: Automated mailing
|
||||
## Author: Rilgamon
|
||||
## SavedVariables: zz_AltMailDB
|
||||
## OptionalDeps: Ace3, BrokerPack, zzLibCommon, zz_itemsdb
|
||||
Common\common.xml
|
||||
pack.xml
|
Loading…
Reference in New Issue