Fixed bug in item remove
Roland Solymosi [06-29-20 - 18:54]
diff --git a/MyCollection/Internals/Classes/Bag.lua b/MyCollection/Internals/Classes/Bag.lua
index 1225b5b..c88f7ae 100644
--- a/MyCollection/Internals/Classes/Bag.lua
+++ b/MyCollection/Internals/Classes/Bag.lua
@@ -58,13 +58,14 @@ function Bag:AddItem(item)
end
function Bag:RemoveItem(bagId, slotId)
+ local item = nil
if bagId == Constants.BagTypes.Worn then
- local item = self.worn[slotId]
+ item = self.worn[slotId]
table.remove(self.worn, slotId)
table.remove(self.savedTableReference[Constants.BagTypes.Worn], slotId)
end
if bagId == Constants.BagTypes.Backpack then
- local item = self.backpack[slotId]
+ item = self.backpack[slotId]
table.remove(self.backpack, slotId)
table.remove(self.savedTableReference[Constants.BagTypes.Backpack], slotId)
end
diff --git a/MyCollection/Internals/Functions/Callbacks.lua b/MyCollection/Internals/Functions/Callbacks.lua
index d15cbc8..7275246 100644
--- a/MyCollection/Internals/Functions/Callbacks.lua
+++ b/MyCollection/Internals/Functions/Callbacks.lua
@@ -7,7 +7,7 @@ local Dependencies = MyCollection.Internals.Dependencies
Functions.Callbacks = {}
local Callbacks = Functions.Callbacks
-function Callbacks.Added(bagId, slotId, item)
+function Callbacks.Added(bagId, slotId, itemObject)
local characterId = Dependencies.Officials.GetCurrentCharacterId()
local item = Classes.Item.New(characterId, bagId, slotId)
if (item ~= nil and item.setId ~= nil and item.setId ~= 0) then
@@ -16,14 +16,14 @@ function Callbacks.Added(bagId, slotId, item)
end
end
-function Callbacks.Removed(bagId, slotId, item)
+function Callbacks.Removed(bagId, slotId, itemObject)
local item = Data.Inventory:RemoveItem(bagId, slotId)
if (item ~= nil) then
Data.Collection:RemoveItem(item)
end
end
-function Callbacks.Updated(bagId, slotId, item)
+function Callbacks.Updated(bagId, slotId, itemObject)
local characterId = Dependencies.Officials.GetCurrentCharacterId()
local item = Classes.Item.New(characterId, bagId, slotId)
if (item ~= nil and item.setId ~= nil and item.setId ~= 0) then