add advanced lua errors handler & fix hud script source path in traceback

This commit is contained in:
MihailRis
2024-11-19 07:26:28 +03:00
parent 2412699b89
commit 66be215101
5 changed files with 35 additions and 7 deletions
+5 -2
View File
@@ -76,13 +76,16 @@ void scripting::on_frontend_close() {
}
void scripting::load_hud_script(
const scriptenv& senv, const std::string& packid, const fs::path& file
const scriptenv& senv,
const std::string& packid,
const fs::path& file,
const std::string& fileName
) {
int env = *senv;
std::string src = files::read_string(file);
logger.info() << "loading script " << file.u8string();
lua::execute(lua::get_main_state(), env, src, file.u8string());
lua::execute(lua::get_main_state(), env, src, fileName);
register_event(env, "init", packid + ":.init");
register_event(env, "on_hud_open", packid + ":.hudopen");