Creating a randomizer script

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

  • V3DigitimesV3Digitimes Posts: 3,150
    edited December 1969

    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.

  • Richard HaseltineRichard Haseltine Posts: 100,886
    edited December 1969

    const isn't supported in DAZ Script 2 (and anyway you would want a variable so different morphs could have different values).

  • V3DigitimesV3Digitimes Posts: 3,150
    edited December 1969

    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 ?

  • Richard HaseltineRichard Haseltine Posts: 100,886
    edited January 2015

    That's strange -the porting to DAZ Script 2 blurb (from the DS3 scripting kit) definitely says

    const: The 'const' keyword is no longer supported.

    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 -

    const testcase = 1;
    print( testcase );
    testcase = 2;
    print( testcase );

    Gives

    1
    2

    as output.

    Post edited by Richard Haseltine on
  • V3DigitimesV3Digitimes Posts: 3,150
    edited December 1969

    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 !

  • Richard HaseltineRichard Haseltine Posts: 100,886
    edited December 1969

    Yes. It looks as if const is just functioning as a long form of var at the moment.

  • V3DigitimesV3Digitimes Posts: 3,150
    edited December 1969

    ... at the moment...
    Well if suddenly my randomisers stop working, I'll know what to update, thanks for the info!

Sign In or Register to comment.