- Added !CommandMeasure bang. Instead of '!PluginBang "MeasureName Arguments' use '!CommandMeasure "MeasureName" "Arguments"'.

- Script: The !CommandMeasure argument must now be Lua code. For example:
!CommandMeasure "MeasureLuaScript" "someVar = 'hello'"
!CommandMeasure "MeasureLuaScript" "SomeFunc()"
This commit is contained in:
Birunthan Mohanathas
2011-07-09 09:23:28 +00:00
parent c2e3b6292d
commit f0fbc0f145
7 changed files with 82 additions and 20 deletions

View File

@ -189,6 +189,35 @@ bool LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, st
return ret;
}
/*
** RunString
**
** Runs given string in the context of the script file.
**
*/
void LuaScript::RunString(const char* str)
{
if (m_Initialized)
{
// Load the string as a Lua chunk
if (luaL_loadstring(m_State, str))
{
LuaManager::ReportErrors(m_State);
}
// Push our table onto the stack
PushTable();
// Pop table and set the environment of the loaded chunk to it
lua_setfenv(m_State, -2);
if (lua_pcall(m_State, 0, 0, 0))
{
LuaManager::ReportErrors(m_State);
}
}
}
//void LuaScript::BindVariable(const char* p_strName, void* p_pValue, const char* p_strTypeName)
//{
// PushTable();

View File

@ -33,8 +33,7 @@ public:
bool IsFunction(const char* funcName);
void RunFunction(const char* funcName);
bool RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue);
static void ReportErrors(lua_State* L);
void RunString(const char* str);
protected:
lua_State* m_State;