12-18-2015, 06:24 PM
(This post was last modified: 12-18-2015, 06:34 PM by Seadragon91.)
It' also possible to use dofile to load a lua file. I have this code, that loads all lua files in the folder from the array folders. This also allows you to structure your files. The code has to be placed outside of a function, in a lua file in your main plugin folder.
function LoadLuaFiles() local folders = { "/code", "/code/classes", "/code/commands" } local localFolder = cPluginManager:GetCurrentPlugin():GetLocalFolder() for _, folder in pairs(folders) do local files = cFile:GetFolderContents(localFolder .. "/" .. folder) for _, file in pairs(files) do if (string.sub(file, #file -3, #file) == ".lua") then dofile(localFolder .. folder .. "/" .. file) end end end end LoadLuaFiles()