JavaScript wrong incrementation
-
Hi,
can somebody explane, why this is incrementing 'tactCount' by 2 instead of one?
var tactCount = 0;
function main() {
var beatNum = arguments[0];if (beatNum == 1) {
tactCount++;
}return [beatNum, tactCount];
}
Thank you
Dill -
Hi,
This code seems to work for me (tested in this patch).
I would hazard a guess that something in your patch is meaning that your beatNum value is being sent twice (the javascript will run whenever is receives input, even if it is identical to the prior input).
A potential way to do a quick and dirty fix would be to stick a 'value changed' actor infront of your javascript actor like so, this will stop the duplicate value being passed onto the javascript:
Tim
-
Edit; Sent the wrong reply to the wrong thread. Oops!
I just tested this on Windows 10, Isadora latest stable (3.0.8f12) works as expected if you just have a JavaScript actor / with the code provided above.
Regarding your example;
I think that you still receive values, but the Comparator that you put in place that only triggers when a 1 is coming in should fix that. So for sure, this is a weird one that may require us to look with you into the patch.
-
There is a known bug in Isadora 3.0.8 that might have caused this behaviour. Entering a value by typing it into the Output of an attached actor (where the output is connected to the input of the JS actor) will cause the code to run twice. This behaviour is corrected for the next release.
-
I guess this was what I just found out. Not 100% sure though.
There is a connection "loop", starting on an js actors output, passing a comparator and some other, and (only at special circumstances) changing an input value of the very same js actor. But it influences the behavior even if there is no "trigger".
See the captures:Edit: wanted to add a gif, but it doesn´t show up.
I try to explane: If I cut the connection between js actor output 4 and comparator on the right, everything works like expected. Keeping the connection, results in the ill behavoir, even if there is no change at output 4 (stays at 0), and the Trigger Value actor in the left stays inactive. -
Thank you for your explanation, but I guess, this was meant for my other thread?
-
You were right; edited my Post.