Locals.variables

Hi there,

As i have troubles with locals.variables and setInterval... i decided to try to really understand how locals.variables work.

So, i tried to set a button's script to increment a locals, and returns its value in the console.

First i thought it was ok, cause i had the expected result, with this :
image

or that

image

or just that

image

Then i took some notes... went back on O-S-C to make another try with another button, to see if i could remember what i had done... and all went wrong... generally it returns NaN, and i don't know why nor what to do...

So... as a starting point : how to increment a locals.variable and returns its value correctly ?

Thank you

locals is initialized as an empty object : {}. At first, locals.plus will be undefined so you have to make sure it's a number before performing operations on it otherwise you'll get NaN (not a number, result of impossible operations).

if (locals.plus === undefined) locals.plus = 0

Thank you very much. Et dire que j'ai essayé ces deux "options" séparemment... Wasn't so far :slight_smile: