[3.0] Adding Custom File Hooks

I`ve been trying to get file hooks in the browser/ Drag and drop to work but without success.

Ive been trying something similar to the following code which prints "hook_added: other true" fine, so I know the hook has been registered as far as the tool is concerned. However when I try and load a renamed text document as a .Timbuktu file, it does not appear as a registered file in the renoise browserother` category so is not bolded there and will not override as it should?

--file hook values
 local my_extensions = {"Timbuktu"}
 local my_print = function(filename) print("Timbuktu Loaded") end
 local browser_cat = "other"

 --file hook table
 local def_table = {category = browser_cat,
 extensions = my_extensions,
 invoke = my_print}

 --if no hook add it
 if not renoise.tool():has_file_import_hook(browser_cat,my_extensions) then
 renoise.tool():add_file_import_hook(def_table)
 end
  
  --THIS PRINT WORKS CONFIRMING HOOK ADDED BUT .Timbuktu FILES ARE NOT REGISTERED IN BROWSER?  

 print("hook_added: "..browser_cat.." "..tostring(renoise.tool():has_file_import_hook(browser_cat, my_extensions)))

Here is some code from Mxb`s fileformats tool which does seem to register in the browser.

function snd_integration_func(filename)  
  mpc2000_loadsample(filename, nil, renoise.song().selected_sample, nil)
 return true
end

snd_integration = { category = "sample",
 extensions = {"snd"},
 invoke = snd_integration_func} -- returns true

if renoise.tool():has_file_import_hook("sample", {"snd"}) == false then
 renoise.tool():add_file_import_hook(snd_integration)
end

Category can not be “other” but must be one of: “song”, “instrument”, “effect chain”, “modulation set”, “phrase”, “sample” or “theme”

Category can not be “other” but must be one of: “song”, “instrument”, “effect chain”, “modulation set”, “phrase”, “sample” or “theme”

Thank you! “New Text Document.Timbuktu” is showing up nice and bold in songs!

I had tried song before but other bugs were getting in the way at the time and I ended up defaulted to “other”

I can see now there is no “other” listed in the allowed table fields. My bad :wacko: