summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/loaditems.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-04-29 20:30:52 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-04-29 20:30:52 -0400
commit6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530 (patch)
treea0a9e142b4741ed109a00059e3b98efc86b25b4d /gamemode/itemsystem/loaditems.lua
parent534ce8e8612da3ba6d610a782eeaf10c9135b947 (diff)
downloadgmstranded-6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530.tar.gz
gmstranded-6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530.tar.bz2
gmstranded-6f6cce0561c19e7af14bcc6e6b1c7de2d5efc530.zip
a halfway commit to show scott
Diffstat (limited to 'gamemode/itemsystem/loaditems.lua')
-rw-r--r--gamemode/itemsystem/loaditems.lua29
1 files changed, 25 insertions, 4 deletions
diff --git a/gamemode/itemsystem/loaditems.lua b/gamemode/itemsystem/loaditems.lua
index 8f8313b..a77ffb3 100644
--- a/gamemode/itemsystem/loaditems.lua
+++ b/gamemode/itemsystem/loaditems.lua
@@ -1,14 +1,35 @@
+//Loads Loads all the items in the gamemode, these should go into gamemode/itemsystem/itmes folder.
+//Also adds a console command gms_printrestable, that prints all the (base) resource tables and their values.
+//Keep in mind that if an item has UniqueData set to true, it's instance may be different than that shown in gms_printrestable
+
GMS.Resources = {}
+
function GMS.RegisterResource( tbl )
- local sname = string.Replace(tbl.Name, " ", "_")
- print("Registering " .. sname)
- GMS.Resources[sname] = tbl
+ if(tbl == nil) then
+ print("/gamemode/itemsystem/loaditems.lua: Attempted to register a nil entity! This might be a bug!")
+ return
+ end
+ if(tbl.Name == nil) then
+ print("/gamemode/itemsystem/loaditems.lua: Attempted to register an item with no name:")
+ PrintTable(tbl)
+ print("This might be a bug!")
+ return
+ end
+ if(tbl.UniqueData) then
+ tbl.UniqueDataID = -1
+ end
+ print("Registering item:" .. tbl.Name)
+ GMS.Resources[tbl.Name] = tbl
end
-function GMS.GetItemByName(name)
+function GMS.GetResourceByName(name)
if(GMS.Resources[name]) then
return GMS.Resources[name]
else
print("Resource " .. name .. " does not exist! This might be a bug!")
end
end
+
+concommand.Add("gms_printrestable",function(ply,cmd,args)
+ PrintTable(GMS.Resources)
+end)