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
36
37
38
39
40
41
42
43
44
|
--[[
A few functions to make it easier to include files and folders
]]
local auto = {}
local function ExecuteOnFolder(dir, recursive, func)
local path = GM.Folder:gsub("gamemodes/","") .. "/gamemode/"
local fpath = table.concat({path,dir,"/*"})
local files, directories = file.Find(fpath,"LUA")
for k,v in pairs(files) do
if string.GetExtensionFromFilename(v) ~= "lua" then continue end
local callpath = table.concat({path,dir,"/",v})
func(callpath)
end
if recursive then
for k,v in pairs(directories) do
local npath = table.concat({dir,"/",v})
ExecuteOnFolder(npath,true,func)
end
end
end
auto.AddLuaCSFolder = function(dir,recursive)
ExecuteOnFolder(dir,recursive,function(f)
if SERVER then AddCSLuaFile(f)
else include(f) end
end)
end
auto.AddLuaSVFolder = function(dir,recursive)
if CLIENT then return end
ExecuteOnFolder(dir,recursive,function(f)
include(f)
end)
end
auto.AddLuaSHFolder = function(dir,recursive)
ExecuteOnFolder(dir,recursive,function(f)
if SERVER then AddCSLuaFile(f) end
include(f)
end)
end
return auto
|