Includes & AddCSLuaFile Loops

Hi guys,

I have a basic understanding of Lua, enough to get me around, with past knowledge in Java.
I needed something beyond my ability to be made, so I paid someone to make an addon.
Sure enough it was made, works, and looks great, but the addon was causing conflicts withthe RDM Manager.

The Error;


[ERROR] addons/damagelog/lua/config/config.lua:10: attempt to index global 'Damagelog' (a nil value)
  1. unknown - addons/damagelog/lua/config/config.lua:10
   2. include - [C]:-1
    3. unknown - addons/model-system/lua/autorun/core.lua:36

Related Includes & AddCSLuaFile Loops;


if SERVER then
	local folder, files, folders, dir;
	
	folder = "config";
	files = file.Find(folder.."/*.lua", "LUA");
	for _, file in ipairs(files) do
		include(folder.."/"..file);
		AddCSLuaFile(folder.."/"..file);
	end
	
	folder = "core";
	files = file.Find(folder.."/*.lua", "LUA");
	for _, file in ipairs(files) do
		include(folder.."/"..file);
		AddCSLuaFile(folder.."/"..file);
	end
	
	folder = "vgui";
	files = file.Find(folder.."/*.lua", "LUA");
	for _, file in ipairs(files) do
		AddCSLuaFile(folder.."/"..file);
	end
else
	local folder, files, dir;
	
	folder = "config";
	files = file.Find(folder.."/*.lua", "LUA");
	for _, file in ipairs(files) do
		include(folder.."/"..file);
	end
	
	folder = "core";
	files = file.Find(folder.."/*.lua", "LUA");
	for _, file in ipairs(files) do
		include(folder.."/"..file);
	end
	
	folder = "vgui";
	files = file.Find(folder.."/*.lua", "LUA");
	for _, file in ipairs(files) do
		include(folder.."/"..file);
	end
end

From the above error, to me it seem that the for loops were looking for all all folder named “config” on the server. This included RDM Manager’s config folder.
Far enough, I’ll contact the Addon Dev, and talk to him. He said I was wrong, his loops are right, and isn’t the issue.
By this point I do not know what to think of it.

So I done my own fixing.


if SERVER then
include("config/modelsys_config.lua");
include("core/sh_core.lua");
AddCSLuaFile("config/modelsys_config.lua");
AddCSLuaFile("vgui/vgui_body.lua");
AddCSLuaFile("core/sh_core.lua");
else
include("config/modelsys_config.lua");
include("vgui/vgui_body.lua");
include("core/sh_core.lua");
end

No more errors, no more issues, everything works. I get into contact again, with what I consider evidence,

What is the truth behind this?
Do these auto include for loops look for ALL FOLDER named “config” on the server, and try to execute them?
Was this a once in a blue moon error, and fix?

Kind Regards,
~Grinny

Those loops will include/AddCSLuaFile all folders called that in all Lua extensions, including gamemodes and addons.

Basically these loops are looking through the entire server, trying to find folders by the name “config” + “vgui” + “core” and trying to Include/execute/send them to the clients.
Indeed shouldn’t be used for folders of these names?