JerboaBurrow / Hop

Lightweight, cross-platform, 2D game engine | ECS; Lua Console; Physics; Tile based
MIT License
0 stars 1 forks source link

Lua empty stack trace, and empty error message #97

Closed Jerboa-app closed 1 year ago

Jerboa-app commented 1 year ago

Fixed in #96

Requires a debug function to be inserted before calling pcall, so instead of lua_dofile we do...

           bool runFile(std::string file)
            {
                if (luaIsOk())
                {
                    lastCommandOrProgram = file;
                    lastStatus = luaL_loadfile(lua, file.c_str());
                    // location of custom error handler
                    int epos = lua_gettop(lua);
                    // push the custom handler
                    lua_pushcfunction(lua, traceback);
                    lua_insert(lua, epos);
                    // run the file passing in the handler
                    lastStatus = lastStatus || lua_pcall(lua, 0, LUA_MULTRET, epos);
                    lua_remove(lua, epos);
                    return handleErrors();
                }
                return false;
            }