View Single Post
Old 12-13-2019, 11:31 AM   #18
Human being with feelings
Join Date: Oct 2018
Posts: 7

Originally Posted by Lokasenna View Post

envSel and 41180 or 40286
If envSel is truthy, and all numbers are truthy, then "envSel and 41180" must be true. That makes the whole condition (truthy thing) or 40286, so Lua knows that it can stop evaluating. It then spits out the last value it checked - 41180 into the surrounding function call.

If envSel is falsy, falsy and 41180 can never be true so it keeps going. (falsy) or 40286 works because one of the values is truthy, so it spits out the first truthy value there - 40286.
@Lokasenna: Wow! Thank you, that's the perfect explanation to a scripting-newbie like me! Trying to understand logical operations in some works of the "prominent" scripters around here regularly gave me brain knots.
Zapatero is offline   Reply With Quote