Script: Fix that some meter related operations (e.g. !HideMeterGroup) did not work in Initialize()

This commit is contained in:
Birunthan Mohanathas 2013-06-23 13:58:48 +03:00
parent f54970e2d7
commit 13ebeccfd7
2 changed files with 15 additions and 2 deletions

View File

@ -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.

View File

@ -35,6 +35,7 @@ public:
void UninitializeLuaScript();
protected:
virtual void Initialize();
virtual void ReadOptions(ConfigParser& parser, const WCHAR* section);
virtual void UpdateValue();