//Helper functions to refactor the init function findRecursive(folderstring,recursive,dofunction) print("Recursive called") local folderpath = "gamemodes/" .. GM.GAMEMODE_FOLDER_NAME .. "/gamemode/" .. folderstring .. "/" print("Attempting to load folderpath " .. folderpath) local files, directories = file.Find(folderpath .. "*", "MOD") print("Files:") PrintTable(files) print("Directories:") PrintTable(directories) for k,v in pairs(files) do dofunction(folderstring .. "/".. v) end if(recursive) then for k,v in pairs(directories) do addResourceFolder(folderstring..v,recursive) end 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