fix hud.* functions cause fatal error if incorrect arguments passes

This commit is contained in:
MihailRis 2024-07-25 00:03:13 +03:00
parent 8dee7facf0
commit 0a8de441b4

View File

@ -67,7 +67,7 @@ static int l_hud_open_block(lua::State* L) {
} }
static int l_hud_show_overlay(lua::State* L) { static int l_hud_show_overlay(lua::State* L) {
auto name = lua::tostring(L, 1); auto name = lua::require_string(L, 1);
bool playerInventory = lua::toboolean(L, 2); bool playerInventory = lua::toboolean(L, 2);
auto assets = engine->getAssets(); auto assets = engine->getAssets();
@ -89,13 +89,13 @@ static UiDocument* require_layout(const char* name) {
} }
static int l_hud_open_permanent(lua::State* L) { static int l_hud_open_permanent(lua::State* L) {
auto layout = require_layout(lua::tostring(L, 1)); auto layout = require_layout(lua::require_string(L, 1));
hud->openPermanent(layout); hud->openPermanent(layout);
return 0; return 0;
} }
static int l_hud_close(lua::State* L) { static int l_hud_close(lua::State* L) {
auto layout = require_layout(lua::tostring(L, 1)); auto layout = require_layout(lua::require_string(L, 1));
hud->remove(layout->getRoot()); hud->remove(layout->getRoot());
return 0; return 0;
} }