Logic Problems

Hi,
I have a runtime listener checking for collisions in my game. I want to ignore collisions with the floor or with objects with no (nil) .myName property.

You can see in the image that without the logic I am able to print the object names fine, but when I try to use the below logic to ignore collisions with the floor it wont print anything to the terminal. I have tried both quotes and no quotes around "floor and “nil”.

function beanCheck(event) obj1 = event.object1.myName; obj2 = event.object2.myName; if(obj1 or obj2 == "floor" or "nil") then test = false; else test = true; end if(test == true) then print(obj1 .. " " .. obj2); end --print(obj1 .. " " .. obj2); end [import]uid: 31694 topic_id: 22057 reply_id: 322057[/import]

try this changing

[lua]if(obj1 or obj2 == “floor” or “nil”) then [/lua]

to

[lua]if obj1 == “floor” or obj1 == “nil” or obj2 == “floor” or obj2 ==
“nil” then[/lua]

not entirely sure if that would work [import]uid: 114118 topic_id: 22057 reply_id: 87649[/import]

This seems to have fixed it. Is there any easier way than just typing out all this?

function beanCheck(event) obj1 = event.object1.myName; obj2 = event.object2.myName; if(obj1 == nil or obj1 == "floor" ) then test = false; elseif(obj2 == nil or obj2 == "floor") then test = false; else test = true; end if(test == true) then print(obj1, " ", obj2); end --print(obj1, obj2); end [import]uid: 31694 topic_id: 22057 reply_id: 87648[/import]