How the hell do I turn this into a tool?

Hi everyone.

Just started making my own tool for the first time so i apologize if these questions are massively n00bish.

After watching a Brian Eno Documentary I wanted to make a tool that would delete a certain portion of notes in a given column, so I made it, and that pretty much works the way I want it to.

But getting it into a menu I can’t seem to do… If I take the registration section out and just execute it, it seems to work fine (well, it doesn’t execute till you exit for some reason but I can live with that)

Here’s my main.lua (apologies, first bit of lua I’ve written):

----------------
-- Registration
----------------

renoise.tool():add_menu_entry {
  name = "Main Menu:Tools:Keef Baker:Note Blaster",
  invoke = function() 
    menubob() 
  end 
}

renoise.tool():add_menu_entry {
  name = "Pattern Editor:Pattern:Note Blaster",
  invoke = function() menubob() end
}

-----------------
-- Actual code
-----------------

-- note killer
function blast_those_notes(probability) 
  local pat_track = renoise.song().selected_pattern_track
  local pat = renoise.song().selected_pattern
  local column = renoise.song().selected_note_column_index
  for line = 1,pat.number_of_lines do
    notey = pat_track:line(line):note_column(column).note_string
    if notey ~= "---" then
    v = math.random (1,100)
      if v > probability then
        pat_track:line(line):note_column(column).note_string = "---"
        pat_track:line(line):note_column(column).instrument_string = ".."
      end
    end
  end
end

-- menu
function menubob()
  local noteboom = 20
  local vb = renoise.ViewBuilder()
  local dialog_title = "Note Blaster"
  local dialog_content = vb:column { 
    vb:text {
      text = "What's the percentage chance of your notes surviving?" 
    },
    vb:slider {
        min = 1.0,
        max = 100,
        value = 20.0,
        notifier = function(value)
          noteboom = value
        end
      },
    vb:text {
      id = "feedback",
      text = "" 
    },
    vb:button {
      text = "ASSASSINATE!",
      notifier = function()
        blast_those_notes(noteboom)
        local feed = vb.views.feedback
        feed.text = ("Killed %.2f of notes. You Monster!"):format(noteboom)
      end
    }
  }
  local dialog_buttons = {
  "Done"
  }
  renoise.app():show_custom_prompt(
    dialog_title, dialog_content, dialog_buttons)
end

Here’s the manifest.xml

<?xml version="1.0" encoding="UTF-8"?>
<RenoiseScriptingTool>
  <ApiVersion>4.0</ApiVersion>
  <Version>1.0</Version>
  <Id>com.keefbaker.NoteBlaster</Id>
  <Author>keef baker [nimonambient@gmail.com]</Author>
  <Category>randomization</Category>
  <Name>Note Blaster</Name>
  <Description>Removes a percentage amount of notes from the selected pattern.</Description>
</RenoiseScriptingTool>

And I’ve put the files in:

C:\Users\keith.baker\AppData\Roaming\Renoise\V3.1.0\Scripts\Tools\com.keebaker.NoteBlaster

But When I reload renoise, it doesn’t appear in any menus or the Tool Browser and I get no errors.

Any ideas what i’ve missed or buggered up?

Also how do you package to xrnx when done, do you just zip and change the extension?

Seems to work fine here (Renoise 3.1) keef. Probably just missed a ‘local’ around lines 27 and 29 for the variables ‘notey’ and ‘v’. You have a API version of 4 (might be for Renoise 3.0) in your manifest, Renoise 3.1 uses API version 5, so that probably needs incrementing. The reason the update isn’t happening until after you click the ‘done’ button is probably because you have a modal dialog prompt rather than a non modal dialog tool window, not that it matters :slight_smile:

Thanks, that’s fantastic.

For future reference how do you convert to xrnx?

For future reference how do you convert to xrnx?

Navigate to within the tool folder (where you’ve got main.lua, manifest.xml etc.) and zip the contents. Then rename to xrnx.

Thanks guys, that’s brilliant!

I’m struggling with a different one now. Are there any diagnostic tools that might show you why a lua script will work fine on it’s own but fail miserably when turned into a tool?

ie: Is there any way of getting error reports out for attempting to import a tool?

If you can’t even install the tool, perhaps the log can tell you something about what went wrong?
Help > Show Log File…

Otherwise, best thing is to start (really!) simple and build from there…

A nice trick if you get tired of reloading the tool over and over on each modification is to add this somewhere in your main.lua:

-- reload tool whenever source has changed
_AUTO_RELOAD_DEBUG = true

Cool. Thanks.

I can’t believe I was debugging for ages and it turns out it was only because I called my xml file manifext.xml instead of manifest.xml

I didn’t see it for ages, then i noticed it’d loaded it as an instrument… I feel like a right wally now!!

Well, I’ve learned a lot today guys, my thanks to you both!