It is recommended to avoid nested statements if, I would try one check if. The best way to be sure is to profile functions and see what works faster.
-- Be paranoid and use lots of parenthesis:
if ( ( (X >= 0) and (Y >= 0) ) and ( (X1 <= 960) and (Y1 <= 720) ) ) then
someCode()
end
This is the same, but easier to read. Good code is not only fast, but also easy to read.
local condition1 = ((X >= 0) and (Y >= 0))
local condition2 = ((X1 <= 960) and (Y1 <= 720))
if (condition1 and condition2) then
someCode()
end
source
share