From 5d5264a8f3da0bd2db69251d6f8445ce73947473 Mon Sep 17 00:00:00 2001 From: jakubg1 <24206305+jakubg1@users.noreply.github.com> Date: Wed, 1 Apr 2026 16:06:17 +0200 Subject: [PATCH] Prefix error messages When a Lua code fails to execute and throws an error, the log line now starts from `lua: Runtime error: `. --- scripting/lua.cpp | 8 ++++---- world/Event.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripting/lua.cpp b/scripting/lua.cpp index 78705a08..58cdd41a 100644 --- a/scripting/lua.cpp +++ b/scripting/lua.cpp @@ -57,15 +57,15 @@ std::string lua::get_error() const void lua::interpret(const std::string& file) const { if (luaL_dofile(state, file.c_str())) { - const char *str = lua_tostring(state, -1); - ErrorLog(std::string(str), logtype::lua); + std::string str = lua_tostring(state, -1); + ErrorLog("lua: Runtime error: " + str, logtype::lua); } } int lua::atpanic(lua_State *s) { - std::string err = lua_tostring(s, 1); - ErrorLog(err, logtype::lua); + std::string err = lua_tostring(s, -1); + ErrorLog("lua: Runtime error: " + err, logtype::lua); return 0; } diff --git a/world/Event.cpp b/world/Event.cpp index fc85af79..10a71bac 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -2141,7 +2141,7 @@ void lua_event::run_() { if (lua_func != LUA_NOREF) lua::dispatch_event(lua_state, lua_func, this, m_activator); } catch (...) { - ErrorLog(simulation::Lua.get_error()); + ErrorLog("lua: Runtime error: " + simulation::Lua.get_error()); } }