Interpreter call lua file in safe mode.

This commit is contained in:
jussi
2022-11-11 21:15:10 +02:00
parent 921ed3b07f
commit 9da3fe6727
2 changed files with 12 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ local texture = -1
local textureSize = { 256, 96 } local textureSize = { 256, 96 }
local res = { 384, 216 } local res = { 384, 216 }
local winSize = RL_GetWindowSize() local winSize = RL_GetWindowSize()
local winScale = 5 local winScale = 4
local framebuffer = -1 local framebuffer = -1
local TILE_SIZE = 32 local TILE_SIZE = 32

View File

@@ -43,7 +43,17 @@ int main( int argn, const char **argc ) {
if ( interpret_mode ) { if ( interpret_mode ) {
stateInitInterpret(); stateInitInterpret();
luaL_dofile( state->luaState, exePath );
lua_State *L = state->luaState;
lua_pushcfunction( L, luaTraceback );
int tracebackidx = lua_gettop( L );
luaL_loadfile( L, exePath );
if ( lua_pcall( L, 0, 0, tracebackidx ) != 0 ) {
TraceLog( LOG_ERROR, "Lua error: %s", lua_tostring( L, -1 ) );
return false;
}
} }
else { else {
printVersion(); printVersion();