summaryrefslogtreecommitdiff
path: root/gamemode/init_utility.lua
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-04-16 04:17:06 -0400
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2016-04-16 04:17:06 -0400
commitf679e1e93372223f468a759f3820f68011b1ddce (patch)
treeb07a42cd633563c2983d4f9920afb826287a3fe0 /gamemode/init_utility.lua
parent28a485732c7e070a24db525da8c90159546908f8 (diff)
downloadgmstranded-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.lua27
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