My tool throws an error because it’s trying to do something before Renoise has fully initialized. I know of
renoise.tool().tool_finished_loading_observable and renoise.too().app_new_document_observable but both of those fire too early when Renoise is loading.
Question: what callback or variable can I use to know that Renoise has fully loaded?
I’m trying to save the song via renoise.app():save_song_as(filename) as soon as Renoise has finished initializing. The error I’m getting is:
std::logic_error: 'can not save documents while the application initializes.'
stack traceback:
[C]: in function 'save_song_as'
main.lua:27: in function 'main'
main.lua:32: in function <main.lua:32>
Maybe I should put a timer in front of my save_song_as() call…
Note, this only happens when Renoise first starts. Everything works as expected after that.
Well I found a work around. Would love to have a better solution in the API but for any future travelers, this works:
function main()
if renoise.tool():has_timer(main) then
renoise.tool():remove_timer(main)
end
-- do stuff here
end
-- wait a couple seconds for the app to be ready after init
renoise.tool():add_timer(main, 2000)