end |
end |
end |
--[[ |
Sendout stuff |
]]-- |
local function GetUName() |
local name = UnitName("player") |
return name.."-"..realm |
end |
local sendouttable = { |
['Tirion'] = { |
['Trade Goods'] = { |
['Leather'] = { |
['Rilgalyco-Tirion'] = { |
['order'] = 1, |
['skip'] = {"Rilgamon-Tirion"}, |
}, |
}, |
['Cloth'] = { |
['Ritalein-Tirion'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Elemental'] = { |
['Rilgana-Tirion'] = { |
['order'] = 1, |
['skip'] = {"Ritalein-Tirion"}, |
}, |
}, |
['Cooking'] = { |
['Rilgana-Tirion'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Enchanting'] = { |
['Rilgana-Tirion'] = { |
['order'] = 1, |
['skip'] = {"Ritalein-Tirion"}, |
}, |
}, |
}, |
['Armor'] = { |
['Plate'] = { |
['Drilane-Durotan'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Cloth'] = { |
['Drilane-Durotan'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Leather'] = { |
['Drilane-Durotan'] = { |
['order'] = 1, |
['skip'] = {"Rilgalyco-Tirion"}, |
}, |
}, |
} |
}, |
['Arygos'] = { |
['Trade Goods'] = { |
['Elemental'] = { |
['Pastorella-Arygos'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Cloth'] = { |
['Pastorella-Arygos'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Cooking'] = { |
['Pastorella-Arygos'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
}, |
['Armor'] = { |
['Plate'] = { |
['Pastorella-Arygos'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
['Cloth'] = { |
['Pastorella-Arygos'] = { |
['order'] = 1, |
['skip'] = {}, |
}, |
}, |
|
} |
} |
} |
local cTip = CreateFrame("GameTooltip",name.."Tooltip",nil,"GameTooltipTemplate") |
local function IsSoulbound(bag, slot) |
cTip:SetOwner(UIParent, "ANCHOR_NONE") |
cTip:SetBagItem(bag, slot) |
cTip:Show() |
for i = 1,cTip:NumLines() do |
if(_G[name.."TooltipTextLeft"..i]:GetText()==ITEM_SOULBOUND) then |
cTip:Hide() |
return true |
end |
end |
cTip:Hide() |
return false |
end |
local function GetDestination(bag,slot) |
if(IsSoulbound(bag, slot)) then return end |
local texture, itemCount, locked, quality, readable, lootable, itemLink, isFiltered = GetContainerItemInfo(bag, slot) |
if(itemLink) then |
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(itemLink) |
if(itemName) then |
itemType = LibBabbleDBR[itemType] |
itemSubType = LibBabbleDBR[itemSubType] |
if(sendouttable[realm] and sendouttable[realm][itemType] and sendouttable[realm][itemType][itemSubType]) then |
local tmp = sendouttable[realm][itemType][itemSubType] |
sort(tmp, function(a,b) |
return (a['order'] or 0) < (b['order'] or 0) |
end) |
for dest,destInfo in pairs(tmp) do |
local doSkip = false |
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 |
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 |
|
sf_new = function() |
local a,b = 0,0 |
local tab = {} |
while(a<=NUM_BAG_SLOTS) do |
b = 1 |
while(b<=GetContainerNumSlots(a)) do |
local texture, itemCount, locked, quality, readable, lootable, itemLink, isFiltered = GetContainerItemInfo(a, b) |
if(itemLink) then |
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, |
itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(itemLink) |
if(itemName) then |
tab[itemType] = tab[itemType] or {} |
tab[itemType][itemSubType] = tab[itemType][itemSubType] or {} |
tab[itemType][itemSubType][#tab[itemType][itemSubType] + 1] = { |
['bag'] = a, |
['slot'] = b, |
} |
end |
end |
b = b + 1 |
end |
a = a + 1 |
end |
for k,v in pairs(tab) do |
local t = LibBabbleDBR[k] |
for c,d in pairs(v) do |
local target,firsttarget |
local count = 0 |
local s = LibBabbleDBR[c] |
print(t,s) |
db['itemdb'][realm] = db['itemdb'][realm] or {} |
db['itemdb'][realm][t] = db['itemdb'][realm][t] or { |
['default'] = { |
[GetUName()] = { |
['order'] = 1, |
['skip'] = {}, |
} |
} |
} |
db['itemdb'][realm][t][s] = db['itemdb'][realm][t][s] or CopyTable(db['itemdb'][realm][t]['default']) |
if(sendouttable[realm]) then |
if(sendouttable[realm][t]) then |
if(sendouttable[realm][t][s]) then |
for g,h in pairs(d) do |
target = GetDestination(tonumber(h['bag']),tonumber(h['slot'])) |
if(target) then |
if(not firsttarget and target ~= GetUName()) then |
firsttarget = target |
end |
if(target==firsttarget) then |
UseContainerItem(tonumber(h['bag']),tonumber(h['slot'])) |
count = count + 1 |
end |
end |
end |
end |
end |
end |
if(firsttarget and count>0) then |
C_Timer.After(0.25, function() |
if(firsttarget and SendMailFrame:IsVisible()) then |
SendMail(firsttarget,"Post",nil) |
SELECTED_CHAT_FRAME:AddMessage("Sending "..firsttarget) |
end |
end) |
return |
end |
end |
|
end |
end |
SendMailFrame:HookScript("OnShow", function() |
C_Timer.After(0.25, sf_new) |
end) |
|
|
local function OnEvent(self, event, arg1, ...) |
if(arg1 == name and event=="ADDON_LOADED") then |
if(PlayerFrame:IsUserPlaced()) then |