diff options
Diffstat (limited to 'gamemode/inventorysystem/equipment/sh_equipment.lua')
| -rw-r--r-- | gamemode/inventorysystem/equipment/sh_equipment.lua | 59 |
1 files changed, 4 insertions, 55 deletions
diff --git a/gamemode/inventorysystem/equipment/sh_equipment.lua b/gamemode/inventorysystem/equipment/sh_equipment.lua index ca7c22d..3c30df15 100644 --- a/gamemode/inventorysystem/equipment/sh_equipment.lua +++ b/gamemode/inventorysystem/equipment/sh_equipment.lua @@ -64,7 +64,7 @@ inv.FindPlaceFor = function(self, item) end --Otherwise, just check if the slot is empty - if self.equiped[item.Equipable] == nil then + if self.equiped[item.Equipable] == nil and slots[self.equiped] ~= nil then return {item.Equipable} else return nil @@ -77,6 +77,7 @@ end inv.Put = function(self,position,item) self.equiped[position[1]] = item + if item.onEquip then item:onEquip(self.owner) end end inv.Has = function(self,string_or_compare_func) @@ -95,6 +96,8 @@ inv.Has = function(self,string_or_compare_func) end inv.Remove = function(self,position) + local item = self.equiped[position[1]] + if item.onUnEquip then item:onUnEquip(self.owner) end self.equiped[position[1]] = nil end @@ -124,57 +127,3 @@ inv.DeSerialize = function(self,data) end inventory.RegisterInventory(inv) - ---[[ -for k,v in pairs(slots) do - local inv = {} - inv.Name = "inv_" .. v - inv.FindPlaceFor = function(self, item) - if self.item == nil then return {} else return nil end - end - inv.CanFitIn = function(self,position,item) - if self.item == nil then return true else return "Inventory slot occupied by a(n)" .. self.item.Name end - end - inv.Put = function(self,pos,item) - self.item = item - end - inv.Has = function(self,prt) - if type(prt) == "string" then - if self.item ~= nil and self.item.Name == prt then return {} else return nil end - elseif type(prt) == "function" then - if prt(self.item) then return {} else return nil end - end - error(string.format("Passed a %s to %s:Has(), expected string or function",type(prt),self.Name)) - end - inv.Remove = function(self,pos) - self.item = nil - end - inv.Get = function(self,pos) - return self.item - end - inv.Serialize = function(self) - if self.item then - local data = ste.CreateStream() - local itemname = self.item.Name - local itemdata = self.item:Serialize() - data:WriteString(itemname) - data:WriteString(itemdata) - return data:ToString() - end - return "" - end - inv.DeSerialize = function(self,str) - print("data was",str) - if str == "" or str == nil then - return table.Copy(self) - else - local data = ste.CreateStream(str) - local itemname = data:ReadString() - local itemdata = data:ReadString() - self.item = itm.GetItemFromData(itemname,itemdata) - end - end - print("Attempting to register inventory with the name " .. inv.Name) - inventory.RegisterInventory(inv) -end -]] |
