From 13ebeccfd7a462b45cdeed41049eb3510551a04b Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sun, 23 Jun 2013 13:58:48 +0300 Subject: [PATCH] Script: Fix that some meter related operations (e.g. !HideMeterGroup) did not work in Initialize() --- Library/MeasureScript.cpp | 16 ++++++++++++++-- Library/MeasureScript.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Library/MeasureScript.cpp b/Library/MeasureScript.cpp index 57108fa1..d75e44e2 100644 --- a/Library/MeasureScript.cpp +++ b/Library/MeasureScript.cpp @@ -54,6 +54,16 @@ void MeasureScript::UninitializeLuaScript() m_HasGetStringFunction = false; } +void MeasureScript::Initialize() +{ + Measure::Initialize(); + + if (m_LuaScript.IsFunction(g_InitializeFunctionName)) + { + m_LuaScript.RunFunction(g_InitializeFunctionName); + } +} + /* ** Runs the function "Update()" in the script. ** @@ -155,9 +165,11 @@ void MeasureScript::ReadOptions(ConfigParser& parser, const WCHAR* section) // Pop PROPERTIES table and our table lua_pop(L, 2); - if (hasInitializeFunction) + if (m_Initialized) { - m_LuaScript.RunFunction(g_InitializeFunctionName); + // If the measure is already initialized and the script has changed, we need to + // manually call Initialize(). + Initialize(); } // Valid script. diff --git a/Library/MeasureScript.h b/Library/MeasureScript.h index 6dafcc8f..c8c5daa4 100644 --- a/Library/MeasureScript.h +++ b/Library/MeasureScript.h @@ -35,6 +35,7 @@ public: void UninitializeLuaScript(); protected: + virtual void Initialize(); virtual void ReadOptions(ConfigParser& parser, const WCHAR* section); virtual void UpdateValue();