Creating a randomizer script
3DSublimeProductions
Posts: 16
I make custom morphs for all figures, is there a way to create a randomizer script that will allow the user to run it on said figure and randomize the dials so that they can get a "random" look each time they click?
Thanks in advance!
3DSublime
Comments
What I would do is
1. save as deprecated pose preset and select only the morphs which I want to randomise.
2. Then I would edit the dsa file, so that at the end, instead of having :
g_oPresetHelper.setNumericProperty( "nameofhemorph", [ 1 ] );
you first declare a random constant :
const a2 = Math.random( );
and replace it
g_oPresetHelper.setNumericProperty( "nameofhemorph", [ a2 ] );
You have to do this for each property you want to randomise and set up your Math.random properly so that it is in the right limits; For instance to have it random between -2 and 2 you write :
const a2 = 2-4*Math.random( ); since Math.random sends between 0 and 1 - 1 excluded (if I remember well).
I made it for sub-properties of materials in the skin randomisers of Amazing Skins, you can have a look at the end of the amazing skins randomisesr files if you have them to see what it looks like.
const isn't supported in DAZ Script 2 (and anyway you would want a variable so different morphs could have different values).
It is very annoying, I have in my commercial products some scripts (.dsa) relying on plenty of :
const varname = math.random() and they work really fine. (well they apply random values as they should)
Should I worry about that (now you could tell me "no" but too late I'm already worried)?
If I make an update should I write :
var varname = math.random () instead ?
That's strange -the porting to DAZ Script 2 blurb (from the DS3 scripting kit) definitely says
but that was of course written a long time ago. Maybe Qt script has been modified and that's rolled over to DS, or maybe DAZ changed it, or maybe the const is being skipped and variables are being created on the fly.
Edit: seems to be the latter -
Gives
1
2
as output.
So const works for now,
but maybe has not always, or not...
and may will not work anymore one day or another..
Finally, next time I'll write var it sounds safer :)
var should be supported for a long time !
Yes. It looks as if const is just functioning as a long form of var at the moment.
... at the moment...
Well if suddenly my randomisers stop working, I'll know what to update, thanks for the info!