Interactive - Arrays in Flow (3)

By Nicolas Holst - 6 Oct, 2017 - 3ds Max

One drawback of the previous post is that it's quite easy to make mistakes when adding and remove additional items. To solve that we can use the Lua functionality that returns the length on an array: #test_array

So instead of writing

test_array[0]=select(1,...);

we're going to write

test_array[#test_array+1]=select(1,...);

 

The benefit is that you don't have to write the array indices. The drawback is that the first entry in the array is now going to start at 1 instead of 0. So the code using the array nees to be updated (the "For Loop" in the previous post needs to be modified so it goes from 1 to 8 instead of 0 to 7).

 

To make it more readable I'm using three "Script Do String" Nodes:

The first one just defines an empty array: 

test_array=[];

 

The second one defines the first five array elements:

test_array[#test_array+1]=select(1,...); test_array[#test_array+1]=select(2,...); test_array[#test_array+1]=select(3,...); test_array[#test_array+1]=select(4,...); test_array[#test_array+1]=select(5,...);

And the third one defines the last three array elements:

test_array[#test_array+1]=select(1,...); test_array[#test_array+1]=select(2,...); test_array[#test_array+1]=select(3,...);

Posted By
Published In
Tags
  • 3ds Max
  • Film & VFX
  • Games
  • Design Visualization
0 Comments
To post a comment please login or register