summaryrefslogtreecommitdiff
path: root/gamemode/utility.lua
blob: 5346cdc2a14912ba6da44f1b137de22c43c324cf (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
//Helper functions to refactor the init

function findRecursive(folderstring,recursive,dofunction)
    local folderpath = "gamemodes/" .. GM.GAMEMODE_FOLDER_NAME .. "/gamemode/" .. folderstring .. "/"
    local files, directories = file.Find(folderpath .. "*", "MOD")
    if(recursive) then
        for k,v in pairs(directories) do
            addResourceFolder(folderstring..v,recursive)
        end
    end
    for k,v in pairs(files) do
        dofunction(folderstring .. "/".. v)
    end
end

//Does AddCSLuaFile() on all files within a folderpath, optionally recursive
//Ex:
//  AddCSLuaFolder("client/extras",true)
function AddCSLuaFolder(folderstring,recursive)
    findRecursive(folderstring,recursive,function(string) AddCSLuaFile(string) end)
end

//Does include() on all files within a folderpath, optionally recursive
//Ex:
//  includeFolder("server/extras",false)
function includeFolder(folderstring,recursive)
    findRecursive(folderstring,recursive,function(string) include(string) end)
end