Very little user support for script writing - Solved!

edited May 2018 in The Commons

I'm not sure how useful these forums are for someone trying their hand at scripting.  I've posted several questions in the screpting area of the forums but onyl one reply, and that was no help.

I'm trying to write a script that changes the Surface image maps for the Diffuse Color and Opacity Strength parameters.  I wish there was more help available but there isn't. I really don't want to shell out $35 each for the scripting tutorials that DAZ offers as they only cover the basics of scripting and I already have a pretty good background in java script.  I have searched on the internet but other that the DAZ SDK there is not a lot of information.

If you look at the attached file, you'll see that where I am stuck is writing new information back to the Surface object so lthat the images change.

 

Post edited by cheznous2029_28ab1adedc on

Comments

  • jag11jag11 Posts: 885

    The line:

    var nOpacImgIndex = sStrNum.valueOf() + 1;

    Should be:

    var nOpacImgIndex = parseFloat(sStrNum) + 1;

    HTH

     

  • CypherFOXCypherFOX Posts: 3,401

    Greetings,

    Have you considered constructing a new texture and putting it into the oDiffProp and oOpacProp using setMap(...)?

    I mean I imagine you're already doing it, but I'd spend a bunch of time experimenting in the interactive script editor trying stuff out, and that'd be high on my list of things to try out.

    --  Morgan

    p.s.  @jag11 is right, valueOf isn't what you want there, it's either parseFloat or parseInt, but either should work.  You also should know that the pattern of 'x = x + 1; if x > n, x = 0' can be transformed into 'x = (x + 1) % 6' and you've eliminated a conditional, reducing the complexity.  Doing that also makes it obvious that you have a pattern of code between the diffuse and opacity that could be extracted to a function.

    My apologies if my suggestions don't help.  Let me know what you've tried, and when I'm back at a computer with DAZ Studio available I'll try and help more than just offering abstract suggestions.

  • CypherFOX said:

    Greetings,

    Have you considered constructing a new texture and putting it into the oDiffProp and oOpacProp using setMap(...)?

    I mean I imagine you're already doing it, but I'd spend a bunch of time experimenting in the interactive script editor trying stuff out, and that'd be high on my list of things to try out.

    --  Morgan

    p.s.  @jag11 is right, valueOf isn't what you want there, it's either parseFloat or parseInt, but either should work.  You also should know that the pattern of 'x = x + 1; if x > n, x = 0' can be transformed into 'x = (x + 1) % 6' and you've eliminated a conditional, reducing the complexity.  Doing that also makes it obvious that you have a pattern of code between the diffuse and opacity that could be extracted to a function.

    My apologies if my suggestions don't help.  Let me know what you've tried, and when I'm back at a computer with DAZ Studio available I'll try and help more than just offering abstract suggestions.

    Thanks for the help here and the other thread.  I did get the script to work and now I am refining it.

    dsa
    dsa
    Next Image.dsa
    4K
  • greymouser69greymouser69 Posts: 501

    You could also try looking at the script writing forum and posting any questions here https://www.daz3d.com/forums/categories/daz-script-developer-discussion  You may need to request special access for it.

Sign In or Register to comment.