mark items for research after crafting
Leandro Silva [01-30-20 - 21:00]
mark items for research after crafting
diff --git a/.LeoTrainer.lua.swp b/.LeoTrainer.lua.swp
new file mode 100644
index 0000000..90729ec
Binary files /dev/null and b/.LeoTrainer.lua.swp differ
diff --git a/LeoTrainer.lua b/LeoTrainer.lua
index a1d3991..7983eb1 100644
--- a/LeoTrainer.lua
+++ b/LeoTrainer.lua
@@ -1,4 +1,4 @@
-
+local craftedItems = {}
local function copy(obj, seen)
if type(obj) ~= 'table' then return obj end
@@ -41,6 +41,45 @@ function LeoTrainer.GetPatternIndexes(craft)
end
end
+local function splitLink(s)
+ local result = {};
+ for match in (s..':'):gmatch("(.-)"..':') do
+ table.insert(result, match);
+ end
+ return result;
+end
+
+function LeoTrainer.compareLinks(link1, link2)
+ local table1 = splitLink(link1)
+ local table2 = splitLink(link2)
+
+ table1[19] = 1 -- reset crafted
+ table2[19] = 1 -- reset crafted
+
+ return table.concat(table1, ':') == table.concat(table2, ':')
+end
+
+local function markItems()
+ if not FCOIS then return end
+
+ local backpack = SHARED_INVENTORY:GenerateFullSlotData(nil,BAG_BACKPACK)
+ for _, crafted in pairs(craftedItems) do
+ for _, data in pairs(backpack) do
+ local itemLinkBag = GetItemLink(data.bagId,data.slotIndex)
+ if GetItemLinkName(itemLinkBag) == GetItemLinkName(crafted) then
+ LeoTrainer.log(data.slotIndex)
+ end
+ if LeoTrainer.compareLinks(crafted, itemLinkBag) then
+ LeoTrainer.log("Marking " .. itemLinkBag .. " for research")
+ FCOIS.MarkItem(data.bagId, data.slotIndex, FCOIS_CON_ICON_RESEARCH, true)
+ break
+ end
+ end
+ end
+ craftedItems = {}
+ --LeoTrainer.log("Done marking")
+end
+
function LeoTrainer.OnCraftFailed(event, station)
end
@@ -51,6 +90,8 @@ function LeoTrainer.OnCraftComplete(event, station)
LeoTrainer.RemoveFromQueue(LeoTrainer.isCrafting)
LeoTrainer.isCrafting = 0
+ table.insert(craftedItems, GetLastCraftingResultItemLink(1))
+
if GetCraftingInteractionType() ~= CRAFTING_TYPE_INVALID and LeoTrainer.continueCrating == true then
zo_callLater(function() LeoTrainer.CraftNext() end, 200)
end
@@ -111,6 +152,7 @@ function LeoTrainer.CraftNext()
LeoTrainer.log("Nothing more to craft at this station.")
LeoTrainer.isCrafting = 0
LeoTrainer.continueCrating = false
+ markItems()
end
function LeoTrainer.stationEnter(eventcode, station)