diff options
| author | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2016-04-16 04:17:06 -0400 |
|---|---|---|
| committer | Alexander Pickering <Alexander.Pickering@anondomain.site90.net> | 2016-04-16 04:17:06 -0400 |
| commit | f679e1e93372223f468a759f3820f68011b1ddce (patch) | |
| tree | b07a42cd633563c2983d4f9920afb826287a3fe0 /gamemode/init_utility.lua | |
| parent | 28a485732c7e070a24db525da8c90159546908f8 (diff) | |
| download | gmstranded-f679e1e93372223f468a759f3820f68011b1ddce.tar.gz gmstranded-f679e1e93372223f468a759f3820f68011b1ddce.tar.bz2 gmstranded-f679e1e93372223f468a759f3820f68011b1ddce.zip | |
Refactored init.lua code for planting console commands
Diffstat (limited to 'gamemode/init_utility.lua')
| -rw-r--r-- | gamemode/init_utility.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gamemode/init_utility.lua b/gamemode/init_utility.lua index ca2d888..5346cdc 100644 --- a/gamemode/init_utility.lua +++ b/gamemode/init_utility.lua @@ -1 +1,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 |
