node.script doesn't receive the number zero 0 (Fixed in Max 8.1.2)
Hi all,
I'm trying to make a node script that will receive numbers from Max as input, I added a handler (Max.addHandler()) with Max.MESSAGE_TYPES.NUMBER as the first argument and I'm printing everything it receives to the Max console. It works fine except for 0. The handler doesn't get triggered. Is that expected behaviour? Is there a way to detect if a 0 is sent to a node.script?
// This is the content of zero.js
const Max = require('max-api')
Max.addHandler(Max.MESSAGE_TYPES.NUMBER, (number) => {
Max.post("Number " + number)
})
I posted about the issue to the Max/MSP facebook group and people suggested that it's a bug so I did a bug report.
Could it be that the 0 is seen as a false boolean?
This article might clear it up: https://codeburst.io/javascript-double-equals-vs-triple-equals-61d4ce5a121a
It sounds probable, I got a reply to my bug report that suggested that as well. Unfortunately 0 is the only falsy value that can be sent from max to node, so we can't do much checking as regular users.
This behaviour was caused by a bug that was fixed in Max 8.1.2.
Max 8.1.2 Release Notes list it under Fixed Bugs as node.script: number 0 (zero) triggers proper handler
http://cycling74.s3.amazonaws.com/support/version_8_1_2.html