src/menucode.cpp
// beforeLoop **********
// This is the code to be executed every time a program zone linked to
// these functions is switched to.

beforeLoop
This is the code to be executed every time a program zone linked to
these functions is switched to.
beforeLoop This is the code to be executed every time a program zone linked to these functions is switched to .
bool MenuLoopCode::beforeLoop()
{
	lua_State* lstate;
	int errCode;
	char* menuToSwitch;
	obscuringSpeed=(255/double(desiredFramesPerSecond))/1;
	if (previousProgramZone==pgzon_gameIntro) {
		screenLightness=0;
	}else{
		screenLightness=255;
	}
	mouseX=0;
	mouseY=0;
	lstate=scriptMan.getLuaObject();
	lua_getglobal(lstate, "errorManager");
	lua_getglobal(lstate, "beforeLoop");
	errCode=lua_pcall(lstate, 0, 0, -2);
	lua_pop(lstate, 1);
	if (errCode!=0) {
		lua_pop(lstate,1);
		logger.logLine("Error calling pcall over beforeLoop");
		return false;
	}
	menuToSwitch="mainMenu";
	lstate=scriptMan.getLuaObject();
	lua_getglobal(lstate, "errorManager");
	lua_getglobal(lstate, "switchToMenu");
	lua_pushstring(lstate, menuToSwitch);
	errCode=lua_pcall(lstate, 1, 0, -3);
	lua_pop(lstate, 1);
	if (errCode!=0) {
		lua_pop(lstate,1);
		logger.logLine("Error calling pcall over switchToMenu");
		return false;
	}
	return true;
}
bool MenuLoopCode :: beforeLoop ( ) { lua_State * lstate ; int errCode ; char * menuToSwitch ; obscuringSpeed = ( 255 / double ( desiredFramesPerSecond ) ) / 1 ; if ( previousProgramZone == pgzon_gameIntro ) { screenLightness = 0 ; } else { screenLightness = 255 ; } mouseX = 0 ; mouseY = 0 ; lstate = scriptMan . getLuaObject ( ) ; lua_getglobal ( lstate , " " ) ; lua_getglobal ( lstate , " " ) ; errCode = lua_pcall ( lstate , 0 , 0 , -2 ) ; lua_pop ( lstate , 1 ) ; if ( errCode != 0 ) { lua_pop ( lstate , 1 ) ; logger . logLine ( " " ) ; return false ; } menuToSwitch = " " ; lstate = scriptMan . getLuaObject ( ) ; lua_getglobal ( lstate , " " ) ; lua_getglobal ( lstate , " " ) ; lua_pushstring ( lstate , menuToSwitch ) ; errCode = lua_pcall ( lstate , 1 , 0 , -3 ) ; lua_pop ( lstate , 1 ) ; if ( errCode != 0 ) { lua_pop ( lstate , 1 ) ; logger . logLine ( " " ) ; return false ; } return true ; }
beforeLoop 
This is the code to be executed every time a program zone linked to
these functions is switched to.
beforeLoop This is the code to be executed every time a program zone linked to these functions is switched to .
// before starting, stop all the playing sounds (belonging to other
 /*	// program zones)
	if (!stopAllSoundResources()) return false;
*/ // calculate the obscuring stuff
 // light all up in 1 second
 // light the screen slowly only when coming from the intro
 // go slowly
 // make it be already lightened
 // give the mouse cursor an initial position
 // EXECUTE THE LUA BEFORE LOOP
 // execute the lua code that manages the before loop
 // take errorManager off the stack
 // there is an extra value there...
 // Time to go to the main menu
 // EXECUTE THE LUA SWITCH TO MENU
 // execute the lua code that manages the menu switching
 // take errorManager off the stack
 // there is an extra value there...
 // all ok
