In this, for the time being, last post of the series we'll use a simpler bit of Lua script for the nodes that add array elements:
for i=1,5,1 do test_array[#test_array+1]=select(i,...); end
writing that out with line breaks to make it more readable:
for i=1,5,1
do
test_array[#test_array+1]=select(i,...);
end
What it does:
- the for loop starts at one and will stop at five with a step size of one
- for each iteration of the loop it adds the respective arg value to the array
The cool thing is that this works even if there is nothing connected to some of the inputs without having to check whether the arg has a value. That also makes it a lot easier to maintain: you can copy the same code in all the nodes, so there is no risk of errors due to mistakes with the arg numbers.