From 2ae89359cea0a46b836034bb0c023ad028f16399 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Mon, 3 May 2021 01:50:55 +0200 Subject: [PATCH] Game variable support --- src/client/game/scripting/lua/context.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/client/game/scripting/lua/context.cpp b/src/client/game/scripting/lua/context.cpp index 14e16d7..716bb76 100644 --- a/src/client/game/scripting/lua/context.cpp +++ b/src/client/game/scripting/lua/context.cpp @@ -11,6 +11,8 @@ #include +namespace _game = game; + namespace scripting::lua { namespace @@ -259,6 +261,19 @@ namespace scripting::lua { logfile::add_player_killed_callback(callback); }; + + game_type["getgamevar"] = [](const sol::this_state s) + { + const auto id = *reinterpret_cast(0x14815DEB4); + + const auto value = _game::scr_VarGlob->childVariableValue[id]; + + _game::VariableValue variable{}; + variable.type = value.type; + variable.u.uintValue = value.u.u.uintValue; + + return convert(s, variable); + }; } }