From d2868db28210b8c4debab2b70dca2833d582fdfd Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Fri, 23 Mar 2018 15:20:30 -0400 Subject: Refactored the inventory system Inventory system now uses flyweight pattern with metatables. --- gamemode/config/sv_newplayer.lua | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'gamemode/config/sv_newplayer.lua') diff --git a/gamemode/config/sv_newplayer.lua b/gamemode/config/sv_newplayer.lua index 1385bf5..229c11e 100644 --- a/gamemode/config/sv_newplayer.lua +++ b/gamemode/config/sv_newplayer.lua @@ -1,20 +1,31 @@ local np = {} local inv = nrequire("inventory/inventory.lua") +nrequire("inventorysystem/equipment/sh_equipment.lua") +nrequire("inventorysystem/shapedinventory/sh_shaped.lua") +nrequire("inventorysystem/prayers/sh_prayers.lua") +nrequire("inventorysystem/skills/sh_skills.lua") +nrequire("inventorysystem/quests/sh_quests.lua") +local log = nrequire("log.lua") --local itm = nrequire("inventory/item.lua") +local data = { + inventories = { + {"Equipment", inv.CreateInventory("Equipment"):Serialize()}, + {"Shaped Inventory",inv.CreateInventory("Shaped Inventory"):Serialize()}, + {"Prayers",inv.CreateInventory("Prayers"):Serialize()}, + {"Skills",inv.CreateInventory("Skills"):Serialize()}, + {"Quests",inv.CreateInventory("Quests"):Serialize()}, + }, +} + np.newdata = function() - return { - inventories = { - {"Equipment", inv.CreateInventory("Equipment"):Serialize()}, - {"Shaped Inventory",inv.CreateInventory("Shaped Inventory"):Serialize()}, - {"Prayers",inv.CreateInventory("Prayers"):Serialize()}, - {"Skills",inv.CreateInventory("Skills"):Serialize()}, - }, - quests = {}, - } + log.debug("newdata asked for") + log.debug(table.ToString(data,"data",true)) + return data end np.newmeta = function() + log.debug("newmeta asked for") return { lastserver = "67.163.245.187:27015", lastlocation = "-1209 1544 -1770" -- cgit v1.2.3-70-g09d2