diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-08-21 21:21:36 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-08-21 21:21:36 -0400 |
| commit | 3571c0bd6a268921287c14a812aa133e9eebbcfa (patch) | |
| tree | 9b756c8d823fa372f4427baaa042d7c832a64683 /gamemode/inventorysystem | |
| parent | 522cdfc0e24b45cf02d8c22cef85fa32408f1376 (diff) | |
| download | artery-3571c0bd6a268921287c14a812aa133e9eebbcfa.tar.gz artery-3571c0bd6a268921287c14a812aa133e9eebbcfa.tar.bz2 artery-3571c0bd6a268921287c14a812aa133e9eebbcfa.zip | |
Fixed a bug with shaped inventory
Shaped inventory was not saveing data correctly.
Diffstat (limited to 'gamemode/inventorysystem')
| -rw-r--r-- | gamemode/inventorysystem/shapedinventory/sh_shaped.lua | 14 |
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 |
