local Folder = GM.Folder:gsub("gamemodes/","").."/gamemode/itemsystem/items" local insert = table.insert print("Hello from loaditems.lua!") GM.Items = GM.Items or {} GM.Recipes = GM.Items or {} --This is so that the client can store info about items/recepies too. local gmitems = (GAMEMODE or GM).Items local gmrecepies = (GAMEMODE or GM).Recipes local itemfiles = {} function RegisterItem(tbl) assert(gmitems[tbl] == nil, "Cannot register 2 items with the same name!") tb = debug.getinfo(2) src = string.sub(tb.source,2) itemfiles[#itemfiles + 1] = src insert(gmitems,tbl) if tbl.Recipe then insert(gmrecepies,tbl) end print("Registered item:", tbl.Name) end (GAMEMODE or GM).LoadItems = function() allfiles = table.Copy(itemfiles) for _,itemfile in pairs(allfiles) do f = file.Read(itemfile,"GAME") c = CompileString(f,itemfile) print("executing",c) if c ~= nil then c() end end end function GetItemByName(name) for k,v in pairs( gmitems ) do if (v.Name == name) then return v end end return nil end function GetRecipeForItem(name) for k,v in pairs( gmrecepies ) do if (v.Name == name) then return v.Recipe,v end end return nil end function GetItemsByClass(class) local Dat = {} for k,v in pairs( gmitems ) do if (v.Class == class) then table.insert(Dat,v) end end return Dat end