diff options
| author | jussi | 2022-11-11 21:15:10 +0200 |
|---|---|---|
| committer | jussi | 2022-11-11 21:15:10 +0200 |
| commit | 9da3fe67273b84f972f322735b0631947fcbc660 (patch) | |
| tree | 8abdc893ec18f2f8d1c1e4a47b6e7d27b4b040d3 | |
| parent | 921ed3b07f4e8c643161a08744b75562055077ff (diff) | |
| download | reilua-enhanced-9da3fe67273b84f972f322735b0631947fcbc660.tar.gz reilua-enhanced-9da3fe67273b84f972f322735b0631947fcbc660.tar.bz2 reilua-enhanced-9da3fe67273b84f972f322735b0631947fcbc660.zip | |
Interpreter call lua file in safe mode.
| -rw-r--r-- | examples/dungeon_crawler/main.lua | 2 | ||||
| -rw-r--r-- | src/main.c | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/examples/dungeon_crawler/main.lua b/examples/dungeon_crawler/main.lua index 9465ed3..546c8ef 100644 --- a/examples/dungeon_crawler/main.lua +++ b/examples/dungeon_crawler/main.lua @@ -5,7 +5,7 @@ local texture = -1 local textureSize = { 256, 96 } local res = { 384, 216 } local winSize = RL_GetWindowSize() -local winScale = 5 +local winScale = 4 local framebuffer = -1 local TILE_SIZE = 32 @@ -43,7 +43,17 @@ int main( int argn, const char **argc ) { if ( interpret_mode ) { 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 { printVersion(); |
