Hi, I am trying to refine the RandomTools created for Scriptographer so that it suits my preference, but I can't figure it out in Javascript. Not knowing a lot of Javascript don't help me either!
Right now, the script will delete a random number of items, depending of the number you give in the dialog box, and the number is somehow in relation with the quantity of items selected.
I would like it to delete a given percentage of the items, no matter how much are selected.
Oups, here is the file!
try something like this
if you want to delete x% of items
for each item in the selection
if Math.random() < x/100 then delete item
Hi Gareth, I don't think I get it… here is the lines 77-85 that I played with, but it won't work, I have an error on the Mathe.random… line.
// loop through selected items
for ( i in sel ) {
var object = sel[i];
if( object.isValid() ) {
// ------------------------------------
// delete
// ------------------------------------
if ( values.b_delete ) {
if (Math.random() <= val_deleteAmt/100) object.remove();
}
} //end isValid()
}
And here is the global file if you wan't to have a look
You need to call values.val_deleteAmt, as it's a property of 'values'
Woooow, it's working :D
That is awsome, thanks a thousand!
Here is the file, if anyone's interested, proudly entitled with a 1.0 at the end.
Does anyone know how I can upload it to the site? It doesn't seam to have a submit button anymore…