From 521d4726addf2e22d607f781d8d027607489b854 Mon Sep 17 00:00:00 2001 From: jyelon Date: Thu, 21 May 2026 19:24:11 -0400 Subject: [PATCH] Make lua tracebacks a little better --- luprex/cpp/core/traceback.cpp | 13 ++++++------- luprex/cpp/core/world-core.cpp | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/luprex/cpp/core/traceback.cpp b/luprex/cpp/core/traceback.cpp index 4842c04b..9856769c 100644 --- a/luprex/cpp/core/traceback.cpp +++ b/luprex/cpp/core/traceback.cpp @@ -50,19 +50,18 @@ int traceback_coroutine(lua_State *L) { if ((ar.currentline > 0) || (*ar.namewhat != 0) || (*ar.what != 'C')) { any = true; lua_pushliteral(L, "\n\t"); - lua_pushfstring(L, "%s:", ar.short_src); - if (ar.currentline > 0) - lua_pushfstring(L, "%d:", ar.currentline); + lua_pushfstring(L, "%s", ar.short_src); + if (ar.currentline > 0 && strcmp(ar.short_src, "")) + lua_pushfstring(L, " line %d", ar.currentline); if (*ar.namewhat != '\0') /* is there a name? */ lua_pushfstring(L, " in function " LUA_QS, ar.name); else { if (*ar.what == 'm') /* main? */ - lua_pushfstring(L, " in main chunk"); + lua_pushfstring(L, " in top-level expression "); else if (*ar.what == 'C' || *ar.what == 't') - lua_pushliteral(L, " ?"); /* C function or tail call */ + lua_pushliteral(L, " in unknown C function"); else - lua_pushfstring(L, " in function <%s:%d>", - ar.short_src, ar.linedefined); + lua_pushfstring(L, " in function on line %d", ar.linedefined); } if (1 + lua_gettop(L) - top > 5) { lua_concat(L, 1 + lua_gettop(L) - top); diff --git a/luprex/cpp/core/world-core.cpp b/luprex/cpp/core/world-core.cpp index 9244e441..bbc66a86 100644 --- a/luprex/cpp/core/world-core.cpp +++ b/luprex/cpp/core/world-core.cpp @@ -859,7 +859,7 @@ void World::invoke_lua_expr(int64_t actor_id, int64_t place_id, std::string_view LuaExtStack LS(L, func); // create the compiled closure. - eng::string error = LS.load(func, datapack, "=invoke"); + eng::string error = LS.load(func, datapack, ""); if (!error.empty()) { // The closure is actually an error message. Do nothing. // This should normally not happen: LuaConsole should filter