zbizu
Legendary OT User
warning: if your libs contain syntax errors, it won't load global.lua
potential fixes are welcome
with this configuration, it will load all files from data/lib/files folder
add to global.lua:
create file loader.lua in data/lib folder:
potential fixes are welcome
with this configuration, it will load all files from data/lib/files folder
add to global.lua:
Code:
dofile('data/lib/loader.lua')
create file loader.lua in data/lib folder:
Code:
------------------------------
-- Loader config
------------------------------
local modDir = "data/lib"
local modOutput = true
local folders = {'files'} -- folders to include
------------------------------
-- Loader
------------------------------
local dirCommand = {'find ', ' -maxdepth 1 -type f'}
-- Windows compability
local platform_windows = false
if io.popen("ver"):read("*all"):find("Windows") then
dirCommand = {'dir "', '" /b /aa'}
platform_windows = true
end
-- lua files loader
local filesCount = 0
for i = 1, #folders do
if modOutput then
io.write('>> Loading ' .. folders[i] .. '... ')
end
for dir in io.popen(dirCommand[1] .. modDir .. folders[i] .. '/' .. dirCommand[2]):lines() do
filesCount = filesCount + 1
local dirstr = (platform_windows and modDir .. folders[i] .. '/' .. dir or dir)
dofile(dirstr)
end
if modOutput then
print(filesCount .. ' file(s) loaded')
end
filesCount = 0
end