file.FindInLua

I try to include all the lua in a folder of my gamemode. I tried this but that doesn’t work…

[lua]
if (!GM) then
GM = GAMEMODE
end
local files = file.FindInLua(GM.Folder …"/gamemode/clientside/*.lua")

for k, v in pairs(files) do
include(“clientside/”… v)
end
[/lua]

[lua]
local files = file.FindInLua(“clientside/*.lua”)

for k, v in pairs(files) do
include(“clientside/”… v)
end
[/lua]

Doesn’t work :S.
I think is the good way but I don’t know why that doesn’t work.
I don’t get any LUA error or something else.
I added


 Msg("Include".. v) 

and I receive no message…

Do you have any files in the clientside directory?

Yeah…
My gamemode is derive from Sandbox so I put the scoreboard of the base gamemode to see if it works.

Fixed! I should use :
[lua]
clfiles = file.FindInLua(“gmname/gamemode/clientside/*.lua”)
[/lua]

[lua]
function IncludeDirectory(dir)

if not(dir) then return end;

local list = file.FindInLua(dir…"/*.lua");
if( list ) then
for _, file in pairs(list) do
include(dir…"/"…file);
Msg("Included:- “…file…”
");
end
end

end
[/lua]
IncludeDirectory(“gmname/gamemode/client”)

[editline]12:45AM[/editline]

Been way to long since i’ve done anything in lua, i had like 6 mind blanks while writing those 10 or so lines…

[lua]
function IncludeDirectory(dir)

if not(dir) then return end;

local list = file.FindInLua(dir…"/*.lua");
if( list ) then
for _, file in pairs(list) do
include("…/…/"…dir…"/"…file); – Because when you include a file, it’s in the gamemode directory
Msg("Included:- “…file…”
");
end
end

end
[/lua]

The lua_temp is mounted into the virtual file system so that you can call file.FindInLua as if the gamemode was actually mounted in the gamemodes/ folder, so I’m fairly certain Flapjack is correct about doing “gamemode/*.lua”