diff options
| author | jussi | 2024-11-22 14:57:31 +0200 |
|---|---|---|
| committer | jussi | 2024-11-22 14:57:31 +0200 |
| commit | cb2b0e4dff5e1d98054f9e5f809fd3a14cd220a1 (patch) | |
| tree | e64efb0dedce13c03011186de34c72a06cad1757 /src/lua_core.c | |
| parent | c9ebe23d6282e96b410dc7687e0be1c4f3ba1b4d (diff) | |
| download | reilua-enhanced-cb2b0e4dff5e1d98054f9e5f809fd3a14cd220a1.tar.gz reilua-enhanced-cb2b0e4dff5e1d98054f9e5f809fd3a14cd220a1.tar.bz2 reilua-enhanced-cb2b0e4dff5e1d98054f9e5f809fd3a14cd220a1.zip | |
WindowShouldClose and custom main loop example.
Diffstat (limited to 'src/lua_core.c')
| -rw-r--r-- | src/lua_core.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lua_core.c b/src/lua_core.c index 3dbd199..aea751a 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1176,12 +1176,13 @@ void luaCallMain() { luaL_dofile( L, path ); /* Check errors in main.lua */ - if ( lua_tostring( state->luaState, -1 ) ) { - TraceLog( LOG_ERROR, "Lua error: %s\n", lua_tostring( state->luaState, -1 ) ); + if ( lua_tostring( L, -1 ) ) { + TraceLog( LOG_ERROR, "Lua error: %s\n", lua_tostring( L, -1 ) ); + state->run = false; + return; } lua_pushcfunction( L, luaTraceback ); int tracebackidx = lua_gettop( L ); - /* Apply custom callback here. */ SetTraceLogCallback( logCustom ); @@ -1200,7 +1201,6 @@ void luaCallMain() { if ( !IsWindowReady() ) { InitWindow( 800, 600, "ReiLua" ); } - /* Set shader locs after we have window. */ if ( IsWindowReady() ) { stateContextInit(); } @@ -1295,6 +1295,7 @@ void luaRegister() { /* Window-related functions. */ assingGlobalFunction( "InitWindow", lcoreInitWindow ); assingGlobalFunction( "CloseWindow", lcoreCloseWindow ); + assingGlobalFunction( "WindowShouldClose", lcoreWindowShouldClose ); assingGlobalFunction( "IsWindowReady", lcoreIsWindowReady ); assingGlobalFunction( "IsWindowFullscreen", lcoreIsWindowFullscreen ); assingGlobalFunction( "IsWindowHidden", lcoreIsWindowHidden ); |
