Interactive - Arrays in Flow (2)

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

In the previous post I used the "Script Do String" node to initialise a Lua array. However that node only has five input so what do you do if you need more than five elements in the array?

Building on the previous example you could do the following:

I've added another "Script Do String" node so that I get more inputs. The Lua code of the origiinal one was:

test_array={}; test_array[0]=select(1,...); test_array[1]=select(2,...); test_array[2]=select(3,...); test_array[3]=select(4,...);

For this new node we only set the values of the array elements and get rid of the bit that tells Lua that test_array is an empty array:

test_array[4]=select(1,...); test_array[5]=select(2,...); test_array[6]=select(3,...); test_array[7]=select(4,...);

In principle you could keep adding nodes, linking their out's to the next one's in. You just have to make sure that you use the right index in the array (in that light it would be easier to add the fifth value to the first node instead of leaving that blank).

Quick tips:

  • if the string isn't too long drag the node wider until the entire string is shown
  • I tend to write the string in Notepad++, that way it's easier to keep an overview of what's going on. And for debugging purposes I tend to delete the last command, try to run it and repeat until the level runs without errors. Then add them back in one by one from the text file.

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