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/inventorysystem/cl_common.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gamemode/inventorysystem/cl_common.lua') diff --git a/gamemode/inventorysystem/cl_common.lua b/gamemode/inventorysystem/cl_common.lua index 559c8f0..bf9fb6f 100644 --- a/gamemode/inventorysystem/cl_common.lua +++ b/gamemode/inventorysystem/cl_common.lua @@ -2,6 +2,7 @@ A bunch of functions that a lot of inventories have in common, dragged out here so bugfixing is easier ]] +local log = nrequire("log.lua") local com = {} --Displays a dropdown of options under the players mouse, if the option is clicked, does the function @@ -20,6 +21,26 @@ function com.CreateMenuFor(menu, tbl) end end +-- Move an item internally between two inventories +function com.MoveItem(f,frominv,toinv) + local frompos = frominv:Has(f) + assert(frompos,string.format("Failed to find item %q in inventory %q",tostring(f),frominv.Name)) + log.debug("Returned position:" .. frompos[1]) + local item = frominv:Get(frompos) + assert(item,string.format("Failed to get item %q out of %q",tostring(f),frominv.Name)) + local topos = toinv:FindPlaceFor(item) + assert(topos,string.format("Failed to find a place in %q to put a %q",toinv.Name,tostring(f))) + + net.Start("art_RequestInvMove") + net.WriteEntity(LocalPlayer()) + net.WriteEntity(LocalPlayer()) + net.WriteUInt(frominv.id,32) + net.WriteUInt(toinv.id,32) + net.WriteTable(frompos) + net.WriteTable(topos) + net.SendToServer() +end + function com.generatereceiver() return function(self,panels,dropped,index,cx,cy) if dropped then -- cgit v1.2.3-70-g09d2