Try this code at the start of your script, there are probably better ways to do it but this works for me.
-- Notifier handler functions
local notifier = {}
function notifier.add(observable, n_function)
if not observable:has_notifier(n_function) then
observable:add_notifier(n_function)
end
end
function notifier.remove(observable, n_function)
if observable:has_notifier(n_function) then
observable:remove_notifier(n_function)
end
end
-- Set up song opening & closing observables
local new_doc_observable = renoise.tool().app_new_document_observable
local close_doc_observable = renoise.tool().app_release_document_observable
-- Set up notifier functions that are called when song opened or closed
local function open_song()
print("A new song was opened")
end
local function close_song()
print("Song was closed")
end
-- Add the notifiers
notifier.add(new_doc_observable, open_song)
notifier.add(close_doc_observable, close_song)