I’m trying to use bitwise operations to figure out if a given value exists within a set of values. For example, I have the numbers 2, 5, and 7. Those are team numbers, and I would like my code to return true if the player’s team matches one of those values. Here is some code:
function( ply )
local validTeams = bit.bor(2, 5, 7)
local binCheck = bit.band( validTeams, ply:Team() )
print("Is valid? "…tostring(binCheck == ply:Team()))
Which will print out true if my team number is one (not good). I was following a guide from the old wiki, but I don’t think the underlying concept of bitwise operations have changed much… Can anyone point out what I’m doing wrong here?