Script: Fixed that GetMeter/GetMeasure/GetVariable functions do not correctly return nil on error

This commit is contained in:
Birunthan Mohanathas 2012-07-18 18:10:25 +03:00
parent ea124f5ccd
commit 6a0f7d988d

View File

@ -74,10 +74,13 @@ static int GetMeter(lua_State* L)
*(CMeter**)lua_newuserdata(L, sizeof(CMeter*)) = meter; *(CMeter**)lua_newuserdata(L, sizeof(CMeter*)) = meter;
lua_getglobal(L, "CMeter"); lua_getglobal(L, "CMeter");
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
return 1; }
else
{
lua_pushnil(L);
} }
return 0; return 1;
} }
static int GetMeasure(lua_State* L) static int GetMeasure(lua_State* L)
@ -91,10 +94,13 @@ static int GetMeasure(lua_State* L)
*(CMeasure**)lua_newuserdata(L, sizeof(CMeasure*)) = measure; *(CMeasure**)lua_newuserdata(L, sizeof(CMeasure*)) = measure;
lua_getglobal(L, "CMeasure"); lua_getglobal(L, "CMeasure");
lua_setmetatable(L, -2); lua_setmetatable(L, -2);
return 1; }
else
{
lua_pushnil(L);
} }
return 0; return 1;
} }
static int GetVariable(lua_State* L) static int GetVariable(lua_State* L)
@ -105,10 +111,13 @@ static int GetVariable(lua_State* L)
if (self->GetParser().GetVariable(strTmp, strTmp)) if (self->GetParser().GetVariable(strTmp, strTmp))
{ {
LuaManager::PushWide(L, strTmp.c_str()); LuaManager::PushWide(L, strTmp.c_str());
return 1; }
else
{
lua_pushnil(L);
} }
return 0; return 1;
} }
static int ReplaceVariables(lua_State* L) static int ReplaceVariables(lua_State* L)