Untitled
unknown
plain_text
4 years ago
2.6 kB
11
Indexable
LoadAddOn("Blizzard_TradeSkillUI")
local ST = LibStub("ScrollingTable")
--
local cols = {}
cols[1] = {
["name"] = "Reagent",
["width"] = 100,
["align"] = "LEFT",
["color"] = {
["r"] = 1.0,
["g"] = 1.0,
["b"] = 1.0,
["a"] = 1.0
},
["colorargs"] = nil,
["bgcolor"] = {
["r"] = 0.0,
["g"] = 0.0,
["b"] = 0.0,
["a"] = 1.0
},
["defaultsort"] = "dsc",
["sort"] = "dsc",
["DoCellUpdate"] = nil,
}
--Same as above, different name label
cols[2] = {
["name"] = "Amount",
["width"] = 100,
["align"] = "LEFT",
["color"] = {
["r"] = 1.0,
["g"] = 1.0,
["b"] = 1.0,
["a"] = 1.0
},
["bgcolor"] = {
["r"] = 0.0,
["g"] = 0.0,
["b"] = 0.0,
["a"] = 1.0
},
["defaultsort"] = "dsc",
["sort"] = "dsc",
["DoCellUpdate"] = nil,
}
local data = {}
--
--
local f = CreateFrame("Frame", "base", UIParent, "BasicFrameTemplateWithInset")
f:SetSize(235, 450)
f:SetPoint("CENTER")
local bob = ST:CreateST(cols, 25, nil, nil, f)
bob:SetData(data, true)
-- bob:SetPoint("CENTER")
-- bob:SetWidth(f:GetWidth())
for k,v in pairs(bob) do print(k,v) end
function addAnother(t, k, v)
t[k]=t[k]+(v or 1)
end
local function has_value (tab, val)
for index, value in ipairs(tab) do
-- We grab the first index of our sub-table instead
if value[1] == val then
return true
end
end
return false
end
local function mathGames(tab, val, count)
for index, value in ipairs(tab) do
-- We grab the first index of our sub-table instead
if value[1] == val then
value[2] = value[2] + count
end
end
return false
end
local shoppingCart = {}
local TRL = TradeSkillFrame.RecipeList
local ZSL = CreateFrame("Button", nil, f, "SharedButtonTemplate")
ZSL:SetSize(50, 20)
ZSL:SetPoint("BOTTOM")
ZSL:SetText("CLICK")
ZSL:SetScript("OnClick",
function()
local recipeID = TradeSkillFrame.RecipeList:GetSelectedRecipeID()
if (not recipeID) then
return
else
local recipeInfo = C_TradeSkillUI.GetRecipeInfo(recipeID)
-- print("ID: "..recipeID..", Name: ",recipeInfo.name)
for i = 1, C_TradeSkillUI.GetRecipeNumReagents(recipeID) do
local name, _, count = C_TradeSkillUI.GetRecipeReagentInfo(recipeID, i)
if has_value(data, name) then
mathGames(data, name, count)
else
table.insert(data, {name, count})
end
end
-- for k,v in pairs(data) do print(k,v)end
-- print"----------"
bob:SetData(data, true)
end
end
)Editor is loading...