Stuck on a basic function,

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 is failing to apply the theme, but gives no error:‘full path to theme’)‘theme name only with extension’)‘theme name without extension’)

I can make it error by using an undeclared variable, so i know the function is working:
*** 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
    print(This filename not exist!)
  print(This path not exist!)

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 without error.

Even the following single line script fails to apply the 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 .. .. '.xrnc' 

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)

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