for details on (text) file i/o, consult http://www.lua.org/pil/21.1.html
to read from or write into a file, we first have to set io.input to the desired filename.
we can use a relative or absolute path to do so, where the base folder being the folder where main.lua is located.
now we can load the file into a variable.
local file_content = io.read("*all")
afaik, it’s not possible to simply insert a device chain with a string. you have to insert devices one by one. individual devices can be manipulated using xml data by changing
but in order to do so, if the device you want to manipulate doesn’t exist yet, you have to add a device using
for detailed information on working with devices, consult the renoise.Track section of Renoise.Song.API
so in order to save and load device chains, you have to either save the devices individually, or save them all in one file and extracting the individual devices from it when needed. one way to do so is serialization. unfortunately, lua doesn’t provide it natively. read this: Table Serialization
EDIT: i forgot to talk about the “paste the device chain data inside the main.lua” part. if you really want just one specific or a few specific devices you want to include into your code directly, you can use multiline strings and string.format().
local my_multiline_string = [[this is a multiline string,
which can be formatted to dynamically
add values, like this integer: %i
or this string: %s]]
local my_number = 3
local my_string = "hi, i'm a string!"
my_multiline_string = string.format(my_multiline_string,
more detailed information on string formatting: http://www.lua.org/pil/20.html