From 81d3d4eb333e226432a591461b84ed12f5ac9a3f Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 21 Jul 2018 19:08:34 -0400 Subject: Various updates * Animation api now allows sequences to be played * items now have a .inv attribute that is set when they are added to shaped or equipment inventories * Refactored the way skill inventory is structured * Added some more methods to cl_common to move items around on a player * Minor update to nrequire to display purple message when asked to include a file that dosn't exist. --- gamemode/core/inventory/cl_invtracker.lua | 3 ++- gamemode/core/inventory/sv_invtracker.lua | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'gamemode/core/inventory') diff --git a/gamemode/core/inventory/cl_invtracker.lua b/gamemode/core/inventory/cl_invtracker.lua index dac1cc2..e6633f9 100644 --- a/gamemode/core/inventory/cl_invtracker.lua +++ b/gamemode/core/inventory/cl_invtracker.lua @@ -4,7 +4,7 @@ local inv = nrequire("inventory/inventory.lua") local itm = nrequire("item.lua") -nrequire("cl_loadglobals.lua") +-- nrequire("cl_loadglobals.lua") --local state = nrequire("cl_state.lua") local q = {} @@ -98,6 +98,7 @@ net.Receive("art_UpdateInventory",function() local item_data = net.ReadData(net.ReadUInt(32)) local item = itm.GetItemFromData(item_name,item_data) known_inventories[id]:Put(position,item) + item.inv = known_inventories[id] --print("Inventorie's observers:") --PrintTable(known_inventories[id].observers) --print("Inventory is now") diff --git a/gamemode/core/inventory/sv_invtracker.lua b/gamemode/core/inventory/sv_invtracker.lua index ed5da4a..b6f6b52 100644 --- a/gamemode/core/inventory/sv_invtracker.lua +++ b/gamemode/core/inventory/sv_invtracker.lua @@ -223,6 +223,20 @@ function plymeta:HasItem(ptr) return false end +--- Gets a refrence to an item without removeing it +-- Gets an item, if you want to look at the fields without changing them. +-- If you do need to change fields, remove the item, change the field, then +-- re-give the item. +--@metamethod player:GetItem(loc) +--@tparam table loc The position of the item (returned by plymeta:HasItem()) +--@treturn itemtbl The item at the location +function plymeta:GetItem(loc) + local nid = loc[1] + local pos = loc[2] + local item = self.data.inventories[nid]:Get(pos) + return item +end + ---A shortcut to remove an item from a player. -- Removes an item from a player and returns the item --@metamethod player:RemoveItem(tbl) -- cgit v1.2.3-70-g09d2