Boolean Math

In other languages, I use boolean results in equations. Is this possible in Lua? ‘true’,‘false’ seems to throw an error even though it is really 1,0

Example:

(math.fmod(2,y) == 0)*(20*.5)

This saves time and (in the past) processing over an if/then statement.

You can’t use boolean true/false values as 1/0 in Lua, but you can still do compact constructions like this: (math.fmod(2,y) == 0) and 20*.5 or 0.

  • Andrew

You can’t use boolean true/false values as 1/0 in Lua, but you can still do compact constructions like this: (math.fmod(2,y) == 0) and 20*.5 or 0.

  • Andrew