From 11188c85c303b7a82960d645d48e11c26997d985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Wed, 14 Jul 2021 08:48:42 +0200 Subject: [PATCH] Fix element identifiers not being accepted by tpt __newindex Becuase *of course* whether it succeds or not depends on whether you've rebuilt menus. With all seriousness, the real culprit here is GameModel::GetToolFromIdentifier, which looks for tools in the menu section tool lists, plus another list with tools that aren't in any menu section. This is absolutely blaphemous, but I don't feel like refactoring this right now. It also wouldn't be a problem in itself, but allocating an element also doesn't rebuild these lists, only changing the MenuSection property and a few other obscure operations do. This makes allocating elements also rebuild these lists. --- src/lua/LuaScriptInterface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index c24093369..8d77221a3 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -2827,6 +2827,7 @@ int LuaScriptInterface::elements_allocate(lua_State * l) luacon_ci->custom_can_move[elem][newID] = 0; luacon_ci->custom_can_move[newID][elem] = 0; } + luacon_model->BuildMenus(); luacon_ci->custom_init_can_move(); }