Nil is not the same as 0, but if you code conditions like “if not renoise.song().selected_note_column_index then” it doesn’t matter whether the false condition is either 0 or nil.
Really?
I honestly thought that it was one of Lua’s peculiarities that the number zero is actually “true”, and not “false”. Are you 100% sure on this, Vv?
It might also be the case that I’ve misunderstood the “if not” testing.
–EDIT: Sorry, misunderstood! Thanks Vv for explaining. Won’t obfuscate thread by replying, but will instead obfuscate my obfuscated post here.
local mynil = nil
local mynul = 0
if mynul < 1 then
print('condition met')
end
if mynil < 1 then
print('i wonder why lua pops up with an error instead')
end
While this works fine:
local mynil = nil
if not mynil then
print('mynil < 1')
else
print('mynil > 0')
end
mynil = 0
if not mynil then
print('mynil < 1')
else
print('mynil > 0')
end
mynil = 1
if not mynil then
print('mynil < 1')
else
print('mynil > 0')
end