Script: Fixed that returning "" in Update() displayed 0 due to r885.

This commit is contained in:
Birunthan Mohanathas
2011-08-01 09:08:11 +00:00
parent 6dfb307636
commit cb4aa0ade3
5 changed files with 25 additions and 18 deletions

View File

@ -147,12 +147,12 @@ void LuaScript::RunFunction(const char* funcName)
** RunFunctionWithReturn
**
** Runs given function in script file and stores the retruned number or string.
** Returns true if the executed function returns a valid value.
** Returns LUA_TNIL when no return.
**
*/
bool LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue)
int LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue)
{
bool ret = false;
int ret = LUA_TNIL;
if (m_Initialized)
{
@ -172,17 +172,13 @@ bool LuaScript::RunFunctionWithReturn(const char* funcName, double& numValue, st
if (lua_isnumber(m_State, -1))
{
numValue = lua_tonumber(m_State, -1);
strValue.clear();
ret = true;
ret = LUA_TNUMBER;
}
else if (lua_isstring(m_State, -1))
{
const char* str = lua_tostring(m_State, -1);
strValue = ConvertToWide(str);
numValue = 0;
ret = true;
ret = LUA_TSTRING;
}
lua_pop(m_State, 2);

View File

@ -32,7 +32,7 @@ public:
bool IsFunction(const char* funcName);
void RunFunction(const char* funcName);
bool RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue);
int RunFunctionWithReturn(const char* funcName, double& numValue, std::wstring& strValue);
void RunString(const char* str);
protected: