// *************************************************************** // Function: InitScriptingSystem.cpp // *************************************************************** #include "Main.h" int LoadConsoleScripts(); //************************************ // Name: InitScriptingSystem // // Initializes the script subsystem. // // Parameters: // // Return: // true - ok // false - errors //************************************ bool InitScriptingSystem() { gpScriptMan=new ScriptManager(&gScriptLog); if (gpScriptMan==NULL) { gCoreLog.SectionFail(); gCoreLog.error("Failed to create an instance of ScriptManager."); return false; } gCoreLog.SectionOk(); //Load the console scripts gCoreLog.Section("Loading Console Scripts..."); if (LoadConsoleScripts()!=0) { gCoreLog.SectionFail(); return false; } gCoreLog.SectionOk(); //Load the game mechanic scripts gCoreLog.Section("Loading game mechanic scripts..."); ScriptModule* pGame_mechanic_scripts=new ScriptModule("global", gpScriptMan); if (pGame_mechanic_scripts->LoadDir("Data/Scripts/GameMechanics/", NULL)!=0) { gCoreLog.error("gameMechanicScripts - Error %d"); gCoreLog.SectionFail(); return false; } gpScriptMan->AddModule(pGame_mechanic_scripts); gCoreLog.SectionOk(); //Register C/C++ functions with the VM gCoreLog.Section("Registering C/C++ Functionality..."); if (gpScriptMan->RegisterStuff()!=0) { gCoreLog.SectionFail(); return false; } gCoreLog.SectionOk(); return true; }