fix hud libraries not removing after on_hud_close & fix segfault on illegal access to hud functions

This commit is contained in:
MihailRis
2025-02-11 16:16:15 +03:00
parent b1740bf7eb
commit 0eeea9dde6
5 changed files with 63 additions and 49 deletions
+17
View File
@@ -0,0 +1,17 @@
#pragma once
#include "api_lua.hpp"
#include "logic/scripting/scripting_hud.hpp"
#include "graphics/render/WorldRenderer.hpp"
#include "engine/Engine.hpp"
template <lua_CFunction func>
inline int wrap_hud(lua_State* L) {
if (scripting::hud == nullptr) {
return luaL_error(
L, "renderer is not initialized yet, see hud.lua on_hud_open event"
);
}
return lua::wrap<func>(L);
}