As a side note, the 'and' and 'or' operators in LUA don't necessarily work the way you expect from other languages. They don't always return false or true; consider for example the following:
Code:
local function blah(myInput)
return (myInput < 5) and "apple" or "orange"
end
What does this code actually do? If myInput is less than 5, it returns the string "apple", and otherwise, it returns the string "orange". In essence, so long as Y is guaranteed to not be nil or false (even 0 as a value is OK as LUA doesn't treat 0 as false), X and Y or Z in LUA is equivalent to the C-style ternary operator X ? Y : Z, a condensed form of "if X then Y else Z end".
Why is this? Because AND in LUA is implemented like this: for X AND Y, if X is false or nil, return X. Otherwise, return Y. Similarly, OR is implemented such that if X is false or nil, return Y, and otherwise, return X. So, in the above function, if myInput is less than 5, the AND function returns "apple", and the return reduces to "'apple' or 'orange'". "apple", being a non-nil string, evaluates to true, and thus the OR returns "apple" as well. If myInput is >= 5, AND returns false, and the return reduces to "false or 'orange'", thus the OR call returns "orange".
A bit of a tangent, but it can sometimes help you find some shortcuts in your coding