Lua WTFs: a boolean apparently isn’t a boolean.


It’s 1:30am, I’ve been working on this for the last few hours (and got afair bit of stuf done), but i can’t wrap my head around this last problem.

This is the code:

if ok == false then

Yeah. Looks simple, right? Except that running it, I get the error ” ?:0: attempt to index field ‘_actions’ (a nil value)”.

And if I change it to if ok == nil, it evaluates as false, despite the LuaDocs saying “both nil and false will act as a false condition in a test expression.”

Discussion on IRC suggests it’s a metatable problem. Which I have no clue how to fix at this point.

===

The strange thing is is that it only seems to fail if ok is false. If ok is true, the expressions is properly evaluated as false. It’s only when ok is false that the strange error appears, which isn’t making much sense.

(Also, getmetatable() seems to be broken in Lightroom – it’s perpetually returning false. Or maybe it’s because I’m using 5.1.4 where Lightroom is using 5.1.2?)

,

  1. No comments yet.
(will not be published)