I think you’re nearly there, but you have to make a loop stepping thru all the track_indexes. A variable statement (local…) doesn’t make sense there.
It should be something like:
for track_index = first_octave_track + 9, first_octave_track, -1 do
[[all your code added]]
end
Loops are your friend! The basic syntax is:
for i=10,1,-1 do
print(i)
end
Every time the loop is looping, all code INSIDE the loop will believe that “i” has a certain value. In this case the value will go from 10 to 1, each looping will add -1 to “i” (=subtracting 1). The last parameter is optional but useful in case you want “i” to step backwards (decrease), which is the most convenient this time.
The first time (first iteration), the loop will believe “i” to be 10. The next iteration “i” will be 9. When “i” reaches 1 the program will exit the loop and continue. Any code after the loop has no clue what “i” is - it was only a local variable within the loop scope.
Later on you will use for pairs/ipairs loops to easily go step by step thru tables. They have quite a simple syntax as well.
PS. I think it might be confusing for a beginner that the code uses variables like track_index and so on. These have nothing to do with what’s in the Renoise API, but are just names that we decide to use for clarity. You might as well name such a variable “t_i” if that suits your taste. It’s all about generating numbers (variables) that we can use for accessing data in the Renoise API or any table. Like creating our own counter that is usable for how Renoise API is indexing all its stuff…