[Closed] Array name with a variable
Hello,
I am digging maxscript for some months and doing some progress, thanks to this forum.
I have this array
first=#("Supercube", "Box004_1")
and would like to create a new empty array named first[1], any ideas?
Thanks
First I’ll tell you how to do it
execute (first[1] + " = #()")
Then I will tell you that you should never need to do this.
First[1] is telling maxscript that you want to get the first index (not the 0th index as other languages do).
In your example
first=#(“Supercube”, “Box004_1”)
first[1]
–returns
“Supercube”
You talk about an empty variable, assuming you mean something like this…?
newVar = first[1]
I think that it is better to rename the first[1] to first01. This way you will know that this is the first element from the first array, but the name of the new array will be correct regarding the maxscript syntax.
There are preserved words and symbols, that maxscript uses. Try to avoid using them. As Dave told you first[1] tells to maxscript to give you the value of the first element of the first array. Using first[1] as a name of variable is wrong.