Game Development Community

Directory Loading

by Taylor Petrick · in Torque Game Engine · 08/20/2008 (6:37 am) · 2 replies

I'd like to have the engine load files from directories with numbers in them, and I don't want to have to write exec(path#); for every single one. These directories will be for patches, so they won't all be there in the first release. Anyways, can I do something like:

for %X{

ifDirectoryExists("scriptsAndAssets\data\patch"%X)
{
exec("scriptsAndAssets\data\patch"%X"\main.cs");
}
else{}
}

I know those functions may not actually exist, but would something like that work?

#1
08/20/2008 (11:23 am)
You can use findFirstFile and findNextFile to accomplish this. For an example you can also look at "loadDirectory", which at least exists in TGEA.

Also findFirst/NextFile are mentioned Here. Even though thats a TGB article, those functions should work the same.
#2
08/22/2008 (3:41 am)
The loadDirectory function is exactly what I needed. I'm using TGEA, just thought I'd post here as it seemed like a general Torque question. Thanks James.