blob: 8afd9b9df5a794d87ef55964b613e70d6535a230 (
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
|
//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
--[[
Provides:
GMS.Resources
A table of resources, keyed by name. You probably shouldn't modify this directly.
GMS.RegisterResource(table_resource)
Adds the table to GMS.Resources, keep in mind that items are indexed by name, so 2 items may not share the same name. The table must also have a .Name field.
GMS.GetResourceByName(string_name)
Returns the resource table associated with the name.
gms_printrestable
A console command that prints out the entire resource table, useful for developers!
]]
GMS.Resources = {}
function GMS.RegisterResource( tbl )
assert(tbl != nil,"Attempted to register a nil entity! This might be a bug!")
assert(tbl.Name != nil,"Attempted to register an item with no name:")
if (tbl.UniqueData) then
tbl.UniqueDataID = -1
end
GMS.Resources[tbl.Name] = tbl
end
function GMS.GetResourceByName(name)
assert(GMS.Resources[name] != nil, "Resource " .. name .. " does not exist! This might be a bug!")
return GMS.Resources[name]
end
concommand.Add("gms_printrestable",function(ply,cmd,args)
PrintTable(GMS.Resources)
end)
|