Skip to content

Commit

Permalink
Add toolData options and fetching toolData items from bank
Browse files Browse the repository at this point in the history
  • Loading branch information
b-morgan committed Jan 5, 2025
1 parent 1827c8b commit 301397f
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Skillet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ function Skillet:InitializeDatabase(player, clean)
if not self.db.realm.queueData[player] or clean then
self.db.realm.queueData[player] = {}
end
if not self.db.realm.toolData then
self.db.realm.toolData = {}
end
if not self.db.realm.toolData[player] or clean then
self.db.realm.toolData[player] = {}
end
if not self.db.realm.auctionData then
self.db.realm.auctionData = {}
end
Expand Down
1 change: 1 addition & 0 deletions SkilletNewsData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Skillet.NewsData = {
data = {
{ header = "Plugins", body = "Add sell to vendor price and profit sorts to Auctionator" },
{ header = "Options", body = "Add 'use bank as alt' and 'use alt banks' options to Classic Era" },
{ header = "Options", body = "Add toolData commands and fetching toolData items from bank" },
},
},
},
Expand Down
87 changes: 86 additions & 1 deletion SkilletOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,91 @@ Skillet.options =
order = 109
},

--
-- commands to manage the manual toolData list
--
tooladd = {
type = 'input',
name = "tooladd",
desc = "Add a tool (tooladd id|link,data)",
get = function()
return value
end,
set = function(self,value)
if not (UnitAffectingCombat("player")) then
if value then
local item, id, data, name, link
local player = Skillet.currentPlayer
DA.DEBUG(0,"value= "..value)
item, data = string.split(",",value)
if string.find(item,"|H") then
id = Skillet:GetItemIDFromLink(item)
else
id = tonumber(item)
end
name, link = GetItemInfo(id)
data = tonumber(data)
DA.DEBUG(0,"id= "..tostring(id)..", name= "..tostring(name)..", data= "..tostring(data)..", link= "..tostring(link))
Skillet.db.realm.toolData[player][id] = { ["name"] = name, ["value"] = data }
end
else
DA.DEBUG(0,"|cff8888ffSkillet|r: Combat lockdown restriction. Leave combat and try again.")
end
end,
order = 110
},
tooldel = {
type = 'input',
name = "tooldel",
desc = "Delete a tool (tooldel id|link)",
get = function()
return value
end,
set = function(self,value)
if not (UnitAffectingCombat("player")) then
if value then
local id
local player = Skillet.currentPlayer
DA.DEBUG(0,"value= "..value)
if string.find(value,"|H") then
id = Skillet:GetItemIDFromLink(value)
else
id = tonumber(value)
end
Skillet.db.realm.toolData[player][id] = nil
end
else
DA.DEBUG(0,"|cff8888ffSkillet|r: Combat lockdown restriction. Leave combat and try again.")
end
end,
order = 111
},
tooldump = {
type = 'execute',
name = "tooldump",
desc = "Print the toolData table",
func = function()
local player = Skillet.currentPlayer
if next(Skillet.db.realm.toolData[player]) == nil then
print("toolData is empty")
end
for id,entry in pairs(Skillet.db.realm.toolData[player]) do
print("id= "..tostring(id)..", name= "..tostring(entry.name)..", value= "..tostring(entry.value))
end
end,
order = 112
},
toolclear = {
type = 'execute',
name = "toolclear",
desc = "Clear the custom reagent data table",
func = function()
local player = Skillet.currentPlayer
Skillet.db.realm.toolData[player] = {}
end,
order = 113
},

--
-- command to reset the position of the major Skillet frames
--
Expand Down Expand Up @@ -1593,7 +1678,7 @@ Skillet.options =
DA.DEBUG(0,"|cff8888ffSkillet|r: Combat lockdown restriction. Leave combat and try again.")
end
end,
order = 110
order = 130
},
}
}
Expand Down
13 changes: 13 additions & 0 deletions UI/ShoppingList.lua
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,19 @@ function Skillet:GetShoppingList(player, sameFaction, includeGuildbank)
end
end
end

if Skillet.db.profile.queue_tools then
for id,entry in pairs(Skillet.db.realm.toolData[curPlayer]) do
local have = GetItemCount(id,false) -- bags only
local bank = GetItemCount(id,true) -- bags + bank
--DA.DEBUG(2,"toolData: id= "..tostring(id)..", name= "..tostring(entry.name)..", value= "..tostring(entry.value))
if have == 0 and bank > 0 then
local entry = { ["id"] = id, ["count"] = 1, ["player"] = curPlayer, ["value"] = 0, ["source"] = "?" }
table.insert(list, entry)
end
end
end

return list
end

Expand Down

0 comments on commit 301397f

Please sign in to comment.