diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-07-21 19:08:34 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-07-21 19:08:34 -0400 |
| commit | 81d3d4eb333e226432a591461b84ed12f5ac9a3f (patch) | |
| tree | d802983c3caf6683f1fd8eb881c7df65afa0d27b /gamemode/inventorysystem/cl_common.lua | |
| parent | bfdf805676684a838dde5d4cdeb3d8c972d5003d (diff) | |
| download | artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.tar.gz artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.tar.bz2 artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.zip | |
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.
Diffstat (limited to 'gamemode/inventorysystem/cl_common.lua')
| -rw-r--r-- | gamemode/inventorysystem/cl_common.lua | 21 |
1 files changed, 21 insertions, 0 deletions
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 |
