made the loader a lua script and added a few useful functions

This commit is contained in:
Evil Factory
2021-09-06 23:30:52 -03:00
parent 995d0d9488
commit 5df4207521
3 changed files with 76 additions and 13 deletions
@@ -0,0 +1,29 @@
local modulePaths = {}
local function endsWith(str, suffix)
return str:sub(-string.len(suffix)) == suffix
end
local function runFolder(folder)
for k, str in pairs(File.DirSearch(folder)) do
local s = str:gsub("\\", "/")
if endsWith(str, ".lua") then
print(s);
dofile(s);
end
end
end
for _, d in pairs(File.GetDirectories("Mods")) do
d = d:gsub("\\", "/")
table.insert(modulePaths, (d .. "/Lua/?.lua"))
if File.DirectoryExists(d .. "/Lua/Autorun") then
runFolder(d .. "/Lua/Autorun");
end
end
setmodulepaths(modulePaths)