Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 922175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:59:10+00:00 2026-05-15T18:59:10+00:00

This works… if ( tileType == water or ( otherObj and otherObj:GetType() == IceBlock

  • 0

This works…

if ( tileType == "water" or 
  ( otherObj and otherObj:GetType() == "IceBlock" )) then
  self:SetNoClip( true )
else
  self:SetNoClip( false )
end

–
These don’t…

self:SetNoClip( tileType == "water" or 
  ( otherObj and otherObj:GetType() == "IceBlock" ))

//----------------------------------------------------------

local noClip = ( tileType == "water" or 
  ( otherObj and otherObj:GetType == "IceBlock" ))
self:SetNoClip( noClip )

The otherObj test just evaluates to whether otherObj is nil or not. The variables given are retrieved in a previous line. The error I get when the application runs is:

unprotected error to call in Lua API(script path...: Did not pass boolean to SetNoClip).

SetNoClip is a function in the application that grabs the argument pushed onto the lua stack via lua_toboolean.

So why does the first work and the second and third return errors?

EDIT:

SetNoClip had 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;
}

The problem is that lua_isboolean doesn’t do any implicit type conversion (but lua_toboolean does) and will only return true for literal boolean values. So if it sees nil, it will return that a boolean wasn’t passed. I just removed the error check for a boolean literal, since people (including me) commonly rely on arguments that aren’t boolean literals being treated correctly as booleans.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T18:59:11+00:00Added an answer on May 15, 2026 at 6:59 pm

    The and operator returns its first argument if that value is something considered non-true, and its second argument otherwise.

    The or operator returns its first argument if it is something considered true, and its second argument otherwise.

    Thus, A or (B and C) can theoretically return any of the following:

    • A if A is a value considered true
    • B if B is a value considered false and A is considered false
    • C if neither of the above is the case

    Note that A, B, and C are not required to be actual boolean values – only things that can be interpreted as booleans. Since nil is considered a false value, it’s possible that the second case is occurring for you, and the argument being passed to SetNoClip is nil instead of true or false.

    One option to fix this would be to explicitly compare with nil, instead of just using the object:

    ( otherObj ~= nil and otherObj:GetType() == "IceBlock" )
    

    since the ~= operator is guaranteed to return a boolean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works fine: jQuery('#my_get_related_keywords').click(function() { if (jQuery('#my_keyword').val() == '') return false; jQuery.getJSON(http://boss.yahooapis.com/ysearch/web/v1/ +jQuery('#my_keyword').val()+? +appid=myAppID
This works... form_dropdown('location', $location_options, $this->input->post('location')); But when I try and use an array to
This works: testDateTime = DateTime.ParseExact(16/10/2010, dd/MM/yyyy, null); This does NOT: string somedate = 16/10/2010;
This works fine [MetadataType(typeof(Area_Validation))] public partial class Area { ... } public class Area_Validation
This works as expected on 30 rows but increases block height over 50% after
This works, and I can't imagine how it might cause problems, but visual studio
This works fine when I run it by hand: #!/bin/bash eval `ssh-agent` ssh-add /usr/bin/scp
This works (places the button in the overflow area): <ToolBar> <Button ToolBar.OverflowMode=Always>Hit me</Button> </ToolBar>
This works: <asp:HyperLink ID=EditGridItemLink runat=server NavigateUrl=<%# GetCustomUrl() %>> link </asp:HyperLink> link value = http://localhost/MyCustomUrl.aspx
This works <a href="@Url.Action("edit", "markets", new { id = 1 })" data-rel="dialog" data-transition="pop" data-icon="gear"

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.