From 457b18620be2b414d68f68f24a22b0f6ba1748f3 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 15 Oct 2023 16:42:19 +0100 Subject: [PATCH] lua: Register globals in a more efficient way --- Source/utils/lua.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/utils/lua.cpp b/Source/utils/lua.cpp index 66e6a8e9c95..f595af64d8b 100644 --- a/Source/utils/lua.cpp +++ b/Source/utils/lua.cpp @@ -108,13 +108,14 @@ void LuaInitialize() #endif // Registering globals - lua["print"] = LuaPrint; - lua["_VERSION"] = LUA_VERSION; + lua.set( + "print", LuaPrint, + "_VERSION", LUA_VERSION); // Registering devilutionx object table - sol::table devilutionx(lua, sol::create); - devilutionx["message"] = LuaPlayerMessage; - lua["devilutionx"] = devilutionx; + lua.create_named_table( + "devilutionx", + "message", LuaPlayerMessage); RunScript("lua/init.lua"); RunScript("lua/user.lua");