Stuck on a basic function, renoise.app():load_theme()

I’m trying to recreate a tool I had that would apply a theme as a song is loaded (theme named after the song), i lost the tool when migrating from linux to windows.

I’m ok with most of it, but the main function renoise.app():load_theme() is failing to apply the theme, but gives no error:

renoise.app():load_theme(‘full path to theme’)
renoise.app():load_theme(‘theme name only with extension’)
renoise.app():load_theme(‘theme name without extension’)

I can make it error by using an undeclared variable, so i know the function is working:

renoise.app():load_theme(dfghjkl)
*** TestPad.lua:15: variable ‘dfghjkl’ is not declared

Where am I going wrong? Any help, or even ‘go read this’ much appreciated.

Probably the error is in not correctly declaring the path to the theme file. The path (a string) must be complete, that is, the exact folder where the file is, including the exact file name and its extension name at the end.

--os.currentdir() --> the folder of your tool
local path=("%stheme/"):format(os.currentdir()) --folder named "theme" inside your tool folder
if (path) then --check if path exist
  local filename=path.."name.extension" --you will probably have to capture this name beforehand.
  if (filename) then --check if filename exist inside your "theme" folder
    renoise.app():load_theme(filename)
  else
    print(This filename not exist!)
  end
else
  print(This path not exist!)
end

This function can be used for an already created folder with your already created theme files.
You can build another function that allows you to select a specific folder and a specific theme file, fetch that file path with a local one, and then call the load_theme() function.

1 Like

Many thanks, I’m still hitting the same problem, even when this script generates the full filename, it still stalls at renoise.app():load_theme(filename) without error.

Even the following single line script fails to apply the theme:

renoise.app():load_theme("C:\Users\tugboat\Documents\RTA\X5DR\RENOISE\themes\sonar.xrnc")

\ is used to backslash special characters in Lua. use \\ instead or /, which works in Windows as well.

See Lua - Strings for more info on this.

that was it! many thanks. :melting_face:

here’s the script for anyone else whose brain sees music in colours :crazy_face:

function startup_notifier()
local path=('C:\\Users\\tugbaot\\AppData\\Roaming\\Renoise\\V3.4.1\\Themes\\')  
local skin =path .. renoise.song().name .. '.xrnc'
renoise.app():load_theme(skin) 
end

if not renoise.tool().app_new_document_observable:has_notifier(startup_notifier) 
   then renoise.tool().app_new_document_observable:add_notifier(startup_notifier)
   else renoise.tool().app_new_document_observable:remove_notifier(startup_notifier)
end
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.