Improve lua error messages
All checks were successful
Make PNG / build-app (push) Successful in 53s

This commit is contained in:
Shylie 2024-06-03 08:10:03 -04:00
parent da1f32a014
commit 6444654f42
2 changed files with 16 additions and 4 deletions

View File

@ -112,7 +112,7 @@ namespace
{ {
const char* error_message = lua_tostring(L, -1); const char* error_message = lua_tostring(L, -1);
luaL_traceback(L, L, error_message, 0); luaL_traceback(L, L, error_message, 1);
const char* err = lua_tostring(L, -1); const char* err = lua_tostring(L, -1);
@ -215,13 +215,24 @@ int main(int argc, char** argv)
luaL_newlib(L, lglerminal_methods); luaL_newlib(L, lglerminal_methods);
lua_setglobal(L, "glerminal"); lua_setglobal(L, "glerminal");
if (luaL_dofile(L, "main.lua") != LUA_OK) lua_pushcfunction(L, message_handler);
const int handler = lua_gettop(L);
if (luaL_loadfile(L, "main.lua") != LUA_OK)
{ {
const char* str = lua_tostring(L, -1); const char* str = lua_tostring(L, -1);
std::cout << str << std::endl;
lua_pop(L, 1); lua_pop(L, 1);
} }
else if (lua_pcall(L, 0, LUA_MULTRET, handler) != LUA_OK)
glerminal_run(init, mainloop, pressed, released); {
const char* str = lua_tostring(L, -1);
std::cout << str << std::endl;
lua_pop(L, 1);
}
else
{
glerminal_run(init, mainloop, pressed, released);
}
lua_close(L); lua_close(L);

View File

@ -296,6 +296,7 @@ namespace glerminal
glfwSwapInterval(0); glfwSwapInterval(0);
glfwSwapBuffers(m_window); glfwSwapBuffers(m_window);
glBlitNamedFramebuffer(m_screen_framebuffer, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glfwSwapInterval(1); glfwSwapInterval(1);
glfwSwapBuffers(m_window); glfwSwapBuffers(m_window);
} }