aboutsummaryrefslogtreecommitdiff
path: root/gamemode/autolua.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-08-09 17:53:52 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-08-09 17:53:52 -0400
commitd4f197a35c207c9891d3f4dc5e9708af48c935de (patch)
treeee8fd3960c3a3fb4ecaf0f62b50d251f007ebaf3 /gamemode/autolua.lua
parent2fe3c4551344870e3784733fce2d95027b5c8382 (diff)
downloadartery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.gz
artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.tar.bz2
artery-d4f197a35c207c9891d3f4dc5e9708af48c935de.zip
Added some weapons
Diffstat (limited to 'gamemode/autolua.lua')
-rw-r--r--gamemode/autolua.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/gamemode/autolua.lua b/gamemode/autolua.lua
index 3f7d07a..12e1d97 100644
--- a/gamemode/autolua.lua
+++ b/gamemode/autolua.lua
@@ -1,9 +1,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
]]
+-- @module autolua
local auto = {}
local function ExecuteOnFolder(dir, recursive, func)
+ recursive = recursive ~= nil and recursive or false
local path = GM.Folder:gsub("gamemodes/","") .. "/gamemode/"
local fpath = table.concat({path,dir,"/*"})
local files, directories = file.Find(fpath,"LUA")
@@ -20,6 +23,10 @@ local function ExecuteOnFolder(dir, recursive, func)
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
+-- @param recursive boolean value that when true includes all sub-folders recursively.
auto.AddLuaCSFolder = function(dir,recursive)
ExecuteOnFolder(dir,recursive,function(f)
if SERVER then AddCSLuaFile(f)
@@ -27,6 +34,10 @@ auto.AddLuaCSFolder = function(dir,recursive)
end)
end
+--- Adds files server side.
+-- Calls include() on all files under a folder, 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.AddLuaSVFolder = function(dir,recursive)
if CLIENT then return end
ExecuteOnFolder(dir,recursive,function(f)
@@ -34,6 +45,10 @@ auto.AddLuaSVFolder = function(dir,recursive)
end)
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.
+-- @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 SERVER then AddCSLuaFile(f) end
@@ -41,4 +56,19 @@ auto.AddLuaSHFolder = function(dir,recursive)
end)
end
+--- Adds resources for the client to download
+-- Calls resource.AddFile() on all files under a directory, recursive.
+-- @param the path to add all files under, relative to the /content/ directory.
+auto.AddContentFolder = function(dir)
+ local path = string.format("gamemodes/artery/content/%s/",dir)
+ local files, directories = file.Find(path .. "*","MOD")
+ for k,v in pairs(files) do
+ resource.AddFile(path .. v)
+ end
+ for k,v in pairs(directories) do
+ local npath = table.concat({dir,"/",v})
+ auto.AddContentFolder(npath)
+ end
+end
+
return auto