I have a slider which is controlling a player. The value of the slider goes between -1 and 1.
I am trying to get the code to recognise when the slider is moved up or down. I am trying using this but nothing works .
var slider = "input slider";
var sliderMov = 0;
if (slider == slider++){
sliderMov = 1;
}
if (slider == slider--){
sliderMov = 0;
}
Any Solution?
In Quartz Composer JavaScript Object I have so far:
var Numb1 = inputs[0];
Object.Numb1Fin = 0;
if (Numb1 == Numb1++){
Object.Numb1Fin = 180;
}
if (Numb1 == Numb1--){
Object.Numb1Fin = 0;
}
outputs[0] = Object.Numb1Fin;
slider++, slider--, Numb1++, and Numb1-- will change the value of the number you are comparing after the comparison. Meaning the comparison will always be true and then the value will change or a change will be attempted. Aside from not being logical you should avoid trying to change the inputs as they should be read only. Here is some JavaScript code which should work for you:
var _oldNumber = null
function (__number outputNumber) main (__number inputNumber, __number patchTime)
{
var result = new Object();
if (!_oldNumber) _oldNumber = inputNumber;
result.outputNumber = inputNumber == _oldNumber ? 0 : inputNumber > _oldNumber ? 1 : -1;
_oldNumber = inputNumber;
return result;
}
You'll need to connect a Patch Time patch to the Patch Time input of the JavaScript patch to force execution every frame.