Game Development Community

Script autoloading

by Patrick Shaw · in Torque Game Builder · 02/06/2007 (5:58 am) · 2 replies

Hi all,
I have written a script that scans my gameScripts directory and executes each one...

function loadScripts(%pattern) {
	echo("begin load...");
	%filename = findFirstFile( %pattern);
	while("" !$= %filename) {
		echo("loading..." SPC %filename);
		exec(%filename);
		%filename = findNextFile( %pattern );
				
	}
}

	loadScripts("~/gamescripts/*.cs");

This works great until I package my game which deletes the *.cs files. The "findFirstFile" function then finds nothing and executes no scripts. I have spotted the findFirstFileMultiExpr which "Finds a file on the file system matching one of several patterns." However, how do I pass multiple patterns to this function? I've tried spaces, commas, semicolons, etc.

#1
02/06/2007 (9:24 am)
Patrick, it would probably be best if you had two copies of this function -- one for 'release' and one for 'dev' -- the release would use the .dso extension, and the dev would use the .cs extension -- rather then making your game search for things that aren't there (wasting CPU cycles and resources)