Make Lua self-initializing
This commit is contained in:
@@ -82,7 +82,6 @@ Emulator::Emulator()
|
||||
}
|
||||
}
|
||||
|
||||
lua.initialize();
|
||||
reset(ReloadOption::NoReload);
|
||||
}
|
||||
|
||||
|
||||
13
src/lua.cpp
13
src/lua.cpp
@@ -27,6 +27,19 @@ void LuaManager::close() {
|
||||
}
|
||||
|
||||
void LuaManager::loadFile(const char* path) {
|
||||
// Initialize Lua if it has not been initialized
|
||||
if (!initialized) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
// If init failed, don't execute
|
||||
if (!initialized) {
|
||||
printf("Lua initialization failed, file won't run\n");
|
||||
haveScript = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int status = luaL_loadfile(L, path); // load Lua script
|
||||
int ret = lua_pcall(L, 0, 0, 0); // tell Lua to run the script
|
||||
|
||||
|
||||
Reference in New Issue
Block a user