We all (the whole Renoise team) are new to Lua as well, have not used Lua before it got part of Renoise, so here are some general Tips & Tricks from my past months experience. Maye this helps someone to dig into all the Lua stuff.
Looking for general Lua code snippets (how to do what in Lua)?
Then this is a good source: Lua user Wiki
Lua counts from 1:
But Renoise counts from 0 in many areas in its GUI. Instruments for example start at 0 in Renoise. To access Renoise instrument no. 0 in Lua, you’ll have to use renoise.song().instruments.
Lua only has one type of numbers, a double precision floating point value. Most of the time this just works. Sometimes, when doing arithmetic stuff with indices, remind taking the floor of the numbers -> my_octave_table[math.floor(note / 12)]
Lua has no classes or real built in OO support, but Renoises Lua impl has. See XRNX docs (classes.lua) for a small rundown
Mind the colon:
Especially when dealing with classes, the use of a dot vs. a colon can be quite confusing at first. Don’t worry, this will make sense at some point. A colon just means: pass whats’s left to it to the called function -> call a method:
some_object.some_function(some_object) --- is the same as: some_object:some_function() -- or renoise.app():show_error("Ouch!")
basically just syntactic sugar.
but properties need no colon. They are no functions:
some_object.some_property -- "member" -- or renoise.song().transport.bpm
Out of the box, Lua is extremely lightweight
… so we’ve added the rest to make it comfortable for us. Probably you have to add some more stuff to make it comfortable for you. A lot of also very low level stuff has been extended in Renoise to make do so. And all this is Renoise specific. You won’t find info on the web or user wiki about this, but only here: Renoise Lua docs