1. #1
    New Member Follow User Gallery
    Join Date
    Oct 2012
    Posts
    13

    Default Loop Command Doubleing

    I'm just starting to learn ZScripting, and there's almost nothing more frustrating when learning than a tutorial example that doesn't work quite right.

    Every time I try to do a Loop command, it executes twice as many times as I indicate. This includes the tutorial (shown bellow) on the very subject. (found here) http://docs.pixologic.com/user-guide...ed-techniques/

    [VarDef,counter,0] //defines a number variable called counter
    [VarDef,message,""] //defines a string variable called message
    [Loop,10, //loop set to 10 times
    [VarSet,counter,(counter+1)] //adds 1 to the value of counter variable
    [VarSet,message,[StrMerge,"The counter is now at : ",counter]] //merges string with value of counter and stores it in message variable
    [Note, message,,1] //displays message for 1 second
    ] //end of Loop


    This block executes 20 times, instead of 10. I've used several values, and in each case it is executed twice as many times as it is set. Is there something missing? Has something changed?


    Thank you kindly,


    Chris

  2. #2
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    If I copy the code into a button and run it, it executes exactly as expected - 10 times. Can you say exactly how you are running the code (i.e. what extra code you are using)?

    And how are you loading the zscript into ZBrush?

  3. #3
    New Member Follow User Gallery
    Join Date
    Oct 2012
    Posts
    13

    Default

    That script is copied from the .txt file I created, in it's entirety. I've even remarked out the concatenation stuff, cut it down to the bare minimum to just see the counting numbers with the same result.

    In ZBrush I simply use the load button in the ZScripts tab to load the .txt file, as instructed by the tutorial. I was going to then stick it in a button, to see if I remembered the first lesson properly, but when I saw the results, I needed to figure out what went wrong.

  4. #4
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Well, I don't know why it's repeating for you. It doesn't for me. But anyway, in general you would place the Loop inside a container command such as a button [IButton] or a routine [RoutineDef]. Otherwise the Loop will only run when the zscript is loaded, which usually you wouldn't want.

    There is a bug in ZBrush where the DefaultZScript is loaded twice on start up, so perhaps the behaviour you're getting is something to do with that. There's no other reason that the loop should repeat, that I can think of.

  5. #5
    New Member Follow User Gallery
    Join Date
    Oct 2012
    Posts
    13

    Default

    Another "just me." problem. Le sigh. !)

    I can put it in a container and see if I get a different behavior.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •