mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-17 19:21:30 +12:00
Make Lua self-initializing
This commit is contained in:
parent
7936a87fb0
commit
4734e0b5e3
2 changed files with 13 additions and 1 deletions
|
@ -82,7 +82,6 @@ Emulator::Emulator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lua.initialize();
|
|
||||||
reset(ReloadOption::NoReload);
|
reset(ReloadOption::NoReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/lua.cpp
13
src/lua.cpp
|
@ -27,6 +27,19 @@ void LuaManager::close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LuaManager::loadFile(const char* path) {
|
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 status = luaL_loadfile(L, path); // load Lua script
|
||||||
int ret = lua_pcall(L, 0, 0, 0); // tell Lua to run the script
|
int ret = lua_pcall(L, 0, 0, 0); // tell Lua to run the script
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue