1. #1
    Senior Member Follow User Gallery
    Join Date
    Jul 2014
    Posts
    111

    Question Trouble with arrays

    Still in remedial Zscripting School I managed to break Zbrush by creating an array

    [VarDef, w(0),"one"]
    [VarDef, w(1),"two"]
    [VarDef, w(2),"three"]


    I'd like to blame the typo in the technical docs on arrays. ;)

    This works, but sets all three elements to the same string, which is limiting ;)
    [VarDef, w(2),"one"]


    This is what I'd expect to type but kicks up the error: Incorrect type of variable input/output

    [VarDef, w(),"one", "two","three"]


    Do you have to specify the number of elements in the array first? because I tried that too to no avail.

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

    Default

    You declare a list variable like this:

    [VarDef, myList(5),""]

    That creates a list variable of 5 items that can contain strings. (It's currently full of empty strings.)

    You can than set the individual values like this:

    [VarSet,myList(0),"apple"]
    [VarSet,myList(1),"pear"]
    [VarSet,myList(2),"orange"]
    [VarSet,myList(3),"lemon"]
    [VarSet,myList(4),"banana"]

    To create a list variable for numbers you would use:
    [VarDef,myNumberList(5),0]

    Make sure you only use [VarDef] to create the list, and you have to decide on the size of the list at that time.

  3. #3
    Senior Member Follow User Gallery
    Join Date
    Jul 2014
    Posts
    111

    Default

    Ha ha! I now see the error of my ways!

Tags for this Thread

Posting Permissions

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