diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-11-27 22:02:47 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-11-27 22:02:47 -0500 |
| commit | 2c4329e2b6e19182a441f79a5c3010011f8ae767 (patch) | |
| tree | e4d8cd88690bed4cfacf2d4df39bdeed97b376f8 /gamemode/autolua.lua | |
| parent | 5f2a8015bd5d2a42e79038bb52f20260d8d97ba0 (diff) | |
| download | artery-2c4329e2b6e19182a441f79a5c3010011f8ae767.tar.gz artery-2c4329e2b6e19182a441f79a5c3010011f8ae767.tar.bz2 artery-2c4329e2b6e19182a441f79a5c3010011f8ae767.zip | |
Vairous updates
Diffstat (limited to 'gamemode/autolua.lua')
| -rw-r--r-- | gamemode/autolua.lua | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/gamemode/autolua.lua b/gamemode/autolua.lua index d550b83..44e146c 100644 --- a/gamemode/autolua.lua +++ b/gamemode/autolua.lua @@ -2,8 +2,12 @@ A few functions to make it easier to include files and folders Thanks to TheMaw for this idea, this entire file is basically ripped form GearFox. - You can AddLua(SV|SH|CS)Folder(foldername) to add that folder in the domain. - Additionally, in the shared domain, if a folder has the folders sv_*.lua and cl_*.lua, and optionally sh_*.lua, these will be included in the server, client, and shared domain respectively. + module functions: + a.AddMixedFolder(foldername, recursive) :: nil + DarkRP style file include(cl_,sv_,sh_) + a.AddCSLuaFolder(foldername,recursive) :: nil + a.AddSHLuaFolder(foldername,recursive) :: nil + a.AddSVLuaFolder(foldername,recursive) :: nil ]] -- @module autolua local auto = {} @@ -26,6 +30,23 @@ local function ExecuteOnFolder(dir, recursive, func) end end +auto.AddMixedFolder = function(dir,recursive) + ExecuteOnFolder(dir,recursive,function(f) + print("Doing file"..f) + if f:find("/cl_%w+%.lua$") then + print("found cl") + if SERVER then AddCSLuaFile(f) else include(f) end + elseif f:find("/sv_%w+%.lua$") then + print("Foudn sv") + if SERVER then include(f) end + else + print("otherwise") + if SERVER then AddCSLuaFile(f) end + include(f) + end + end) +end + --- Adds files client side. -- Calls AddCSLuaFile on all files under a folder server side, and include() client side, if the recursive flag is checked, calls all files under all folders as well. -- @string dir The directory relative to /gamemode/ to add client side @@ -49,19 +70,13 @@ auto.AddLuaSVFolder = function(dir,recursive) end --- Adds files server side. --- Calls include() and AddCSLuaFile() on all files under a folder server side, and include() client side, if the recursive flag is checked, calls all files under all folders as well. If the file starts with cl_ it will only be included on the client side, if the files starts with sv_ it will only be included on the server side. +-- Calls include() and AddCSLuaFile() on all files under a folder server side, and include() client side, if the recursive flag is checked, calls all files under all folders as well. -- @string dir The directory relative to /gamemode/ to add client side -- @param recursive boolean value that when true includes all sub-folders recursively. auto.AddLuaSHFolder = function(dir,recursive) ExecuteOnFolder(dir,recursive,function(f) - if f:find("cl_%a*.lua") then - AddCSLuaFile(f) - elseif f:find("sv_%a.lua") then - if SERVER then include(f) end - else - if SERVER then AddCSLuaFile(f) end - include(f) - end + if SERVER then AddCSLuaFile(f) end + include(f) end) end |
