ZBrushCentral

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. :wink:

This works, but sets all three elements to the same string, which is limiting :wink:
[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.

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.

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