Javascript Triggers



  • Hi,

    I'm currently updating all my old user actors with a lot of math to one javascript actor.
    In this i found a challenge if i want to trigger some code at a specific time.
    or give an output trigger
    I wondered if there is a command to look at a trigger input and to send a trigger output?
    I now did it like this
    **Input Trigger:**

    var Triggervalue=9999;

    function main(){

    if(arguments[0] != Triggervalue){

    //Do something

    Triggervalue=arguments[0];}

    }

    This works when you attach a toggle actor in front of it.
    **Output Trigger**

    var Triggertrue = 0;

    function main(){

    //if (something happens){Triggertrue==1;}

    if (Triggertrue ==1){

    array[0]=100;

    Triggertrue =0;}

    }

    This works when you attach a comparator =100 to it.
    Is there a better way?


  • for me the code depends on the rest of the functionality,  but attached is a basic patch

    the "input trigger approach" doesn't work with a trigger that's why i placed a macro in front
    @mark the js actor is input is mutable, but if we change it to an trigger input it still performs like a number input (no auto reset to false or 0) is it a bug or has it something to do that there is no "timbase" in a js actor

    876c81-js_trigger.izz


  • Tech Staff

    You need to remember that the JS will run everytime any input is received, and will output to all outputs.

    I find it most useful to use the JS actor in combination with other actors to form a user actor.
    One approach I have taken before is to use JS to work out the logic for a number of states, and simply output a number that represents the state.
    Followed by a Selector, or comparator or etc... to do whatever is needed. This can work well also for multiple outputs where the state defines which outputs should be used next.
    The JS actor is not meant to replace the native Isadora actors, but to rather enhance their usage and offer some additional functionality. (see: the javascript sort() function)

Log in to reply
 

Looks like your connection to TroikaTronix Community Forum was lost, please wait while we try to reconnect.