summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/loaditems.lua
blob: a77ffb34e4e5884b2eea3f1b35147c73f48039c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 )
  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.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)