jeudi 3 mars 2016

No repeat randomizing function

the function rnd_act_select() is randomizing four functions further in the code, it is called by a button in Photoshop I have set and everything is working well, but I don't know how to set the randomization with no repeat of the cases until all are executed. Could someone give me a solution to this problem? Thank you.

function rnd_act_select() {
    // random selection
    NumberOfFunctions = 4;//Number of functions in your switch statement.
    var ran = Math.floor(Math.random() * NumberOfFunctions);

    switch(ran) {
        case 0: func_one(); break;
        case 1: func_two(); break;
        case 2: func_three(); break;
        case 3: func_four(); break;
        default : return;
    }
};




Aucun commentaire:

Enregistrer un commentaire