View Full Version : can a script pick a random action?


okplayer
03-24-2005, 02:23 PM
Given a specific set of actions, is there any way to make a script randomly pick one of the actions and apply it to an image?

DannyRaphael
03-24-2005, 03:43 PM
Given a specific set of actions, is there any way to make a script randomly pick one of the actions and apply it to an image?

One way to do this would be as follows...

Suppose you had 10 candidate actions...
* The script would include commands to execute each of them, say, via a table of action names or individual "DoAction" commands
* Generate a random number 0-9 within the script
* Execute the corresponding action

Don't ask me how to "code this" :), but functionally this would work. Ro and Rex are the resident coding experts.

HTH...

~Danny~

xbytor
03-31-2005, 02:34 PM
Try something like:

var actions = [
"act1",
"act2",
"act3",
"act4",
/...
"actN",
];

var randomAction = actions[Math.floor(Math.random() * actions.length)];

byRo
03-31-2005, 03:23 PM
Ro and Rex are the resident coding experts.

I think you can include xbytor in your list - seems like he's got it nailed :)


xbytor
03-31-2005, 04:12 PM
I think you can include xbytor in your list - seems like he's got it nailed :)


Thanks. While this may be true, I am an infrequent visitor as opposed to 'resident'.