/*
 *	main.cs for all TGB-based games.
 *	Copyright World-Loom, 2009
 */
function Main::loadMod(%mod) {
	%mod = strlwr(%mod);
	setModPaths(getModPaths() @ ";" @ %mod);
	return exec(%mod @ "//" @ %mod @ ".cs");
}

function Main::loadMods(%mods) {
	$Main::mods = %mods;
	for(%i=0; %i<getWordCount(%mods); %i++) {
		%mod = getWord(%mods, %i);
		echo("Loading mod '" @ %mod @ "'...");
		if(Main::loadMod(%mod))
			schedule(%i+1, 0, %mod @ "::initialize");
		else
			echo("Load failed!");
	}
}

function onExit() {
	for(%i=0; %i<getWordCount($Main::mods); %i++) {
		%mod = getWord($Main::mods, %i);
		echo("Finalizing mod '" @ %mod @ "'...");
		eval(%mod @ "::finalize();");
	}
	echo("Quitting.");
}

Main::loadMods("Common Extern Game");
