From f4ee62bb0725a3ae94477b2818071f506e4dfd9f Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Fri, 13 Jan 2017 20:33:59 -0500 Subject: Finished up shaped inventory, and more work on shared functions. --- gamemode/core/inventory/item.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gamemode/core/inventory/item.lua') diff --git a/gamemode/core/inventory/item.lua b/gamemode/core/inventory/item.lua index 86bd105..354472a 100644 --- a/gamemode/core/inventory/item.lua +++ b/gamemode/core/inventory/item.lua @@ -32,11 +32,12 @@ function itm.RegisterItem(tbl) assert(tbl[v] ~= nil, string.format("Attempted to register item without field %q",v)) end assert(items[tbl.Name] == nil, string.format("Attempted to register 2 items with the same name %q",tbl.Name)) + items[tbl.Name] = tbl log.debug("Registered item: " .. tbl.Name .. "\n") end function itm.GetItemByName(name) - assert(items[name] ~= nil,string.format("Attempted to get item with invalid name %q",name)) + assert(items[name] ~= nil,string.format("Attempted to get item with invalid name %q Valid item names are:\n\t%s",name,table.concat(table.GetKeys(items),"\n\t"))) return items[name] end @@ -53,7 +54,7 @@ function itm.DeriveItem(tbl,name) --Create a flywieght copy local ret = tbl local mt = { - __index = function(tbl,key) + __index = function(ntbl,key) return items[name][key] end } -- cgit v1.2.3-70-g09d2