aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gamemode/inventorysystem/shapedinventory/sh_shaped.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/gamemode/inventorysystem/shapedinventory/sh_shaped.lua b/gamemode/inventorysystem/shapedinventory/sh_shaped.lua
index 7c171c3..bb35d2d 100644
--- a/gamemode/inventorysystem/shapedinventory/sh_shaped.lua
+++ b/gamemode/inventorysystem/shapedinventory/sh_shaped.lua
@@ -51,6 +51,7 @@ function inv:CanFitIn(tbl,item)
end
function inv:Put(tbl,item)
+ print("Calling put")
--Set the item's shape to true
for rn,row in ipairs(item.Shape) do
@@ -112,22 +113,29 @@ function inv:Serialize()
local ret = {}
for k,v in pairs(self.tracker) do
if type(v) == "table" then
- ret[v.Name] = {k,v:Serialize()}
+ local row = math.ceil(k / self.width)
+ local col = (k % self.width)
+ ret[v.Name] = {{row,col},v:Serialize()}
end
end
return util.TableToJSON(ret)
end
function inv:DeSerialize(str)
- --TODO:Implement
+ print("Deserialize str is", str)
local ret = table.Copy(self)
local tbl = util.JSONToTable(str)
+ print("unjsoned is",tbl,type(tbl))
+ PrintTable(tbl)
for k,v in pairs(tbl) do
local name = k
local pos = v[1]
local data = v[2]
local item = itm.GetItemFromData(name,data)
- self:Put(pos,item)
+ print("Got item",item)
+ PrintTable(item)
+ print("got pos",pos)
+ ret:Put(pos,item)
--ret.tracker[pos] = itm.GetItemFromData(name,data)
end
return ret