It works...
if ( tileType == "water" or
( otherObj and otherObj:GetType() == "IceBlock" )) then
self:SetNoClip( true )
else
self:SetNoClip( false )
end
- Is not...
self:SetNoClip( tileType == "water" or
( otherObj and otherObj:GetType() == "IceBlock" ))
local noClip = ( tileType == "water" or
( otherObj and otherObj:GetType == "IceBlock" ))
self:SetNoClip( noClip )
The test otherObjsimply evaluates whether otherObj is nilor not. The specified variables are retrieved in the previous line. The error I get when starting the application:
unprotected error to call in Lua API(script path...: Did not pass boolean to SetNoClip).
SetNoClip is a function in an application that grabs an argument pushed onto the lua stack through lua_toboolean.
So why the first job and the second and third error return?
EDIT:
SetNoClip has this definition.
int GameObject::LuaSetNoClip( lua_State *L ) {
if ( !lua_isboolean( L, -1 )) {
LogLuaErr( "Did not pass boolean to SetNoClip for GameObject: " + m_type );
return luaL_error( L, "Did not pass boolean to SetNoClip" );
}
m_noClip = lua_toboolean( L, -1 );
return 0;
}
, lua_isboolean ( lua_toboolean does) true . , nil, , . , ( ) , , booleans.