bool CommonAPI::InitAS() { engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); RegisterStdString(engine); RegisterAPI(); CScriptBuilder builder; if(builder.StartNewModule(engine, "MyModule") < 0) FILE_LOG(logERROR) << "Unrecoverable error while starting a new module."; string scriptPath = exePath.substr(0, exePath.find_last_of(".")).append(".tes"); if(builder.AddSectionFromFile(scriptPath.c_str()) < 0) FILE_LOG(logERROR) << "Unable to load script." << scriptPath; else FILE_LOG(logINFO) << "Script " << scriptPath << " loaded successfully."; if(builder.BuildModule() < 0) FILE_LOG(logERROR) << "Please correct the errors in the script and try again."; module = engine->GetModule("MyModule"); return true; }
CCustomCtrl::CCustomCtrl(int nID, LPCSTR lpcszPath) : RUGE::CControl(nID) , m_luaState(true) { RegisterAPI(m_luaState); m_luaState->CheckStack(LUA_STACKSIZE); if (m_luaState->DoFile(lpcszPath)) { printf("Error: %s½Å±¾´íÎó\n", lpcszPath); system("pause"); } }