TIR 0 = truthy
Posted: Fri Oct 07, 2016 3:30 pm
Today I remembered: In Lua, number 0 is a truthy value (only `nil` and `false` are falsey, everything else, including empty string, is truthy).
So if you're using % in an on_tick event handler, bear that in mind... you can't just use "if not game.tick % 180 then", you have to do something like:
Code: Select all
if 0 then
game.print('truthy') -- prints 'truthy' to console
end
Code: Select all
script.on_event( defines.events.on_tick, function()
if game.tick % 180 == 0 then
-- do something every 180 ticks
end
end