Some questions regarding LUA editor / LUA api

Hi,

have a bunch of beginner questions regarding the LUA editor/ LUA api:

  • Is there a way to re-indent the code?

  • Is there a shortcut to “find next”, like Apple-G on OSX?

  • Is there an observable for general “file renaming”, deletion and creation ? Or an observable when the disk browser will unfocus?

  • Can I change the current path of the current song?

  • Is there a default song path available?

  • is it possible to rename the current song using LUA, so that this new name will be used, if the save-song-dialogue appears and in the window title bar?

Thanks.

:frowning: No answer means: WTF RTFM ?

  • Is there a way to re-indent the code?
  • Is there a shortcut to “find next”, like Apple-G on OSX?

Select a multi-line block of text in the editor, then use [Tab] to indent, or [Shift] + [Tab] to un-indent.

[Ctrl] + [G] will find the next match, if a search has previously been made using [Ctrl] + [F]. You can also simply continue pressing [Return] in the find box, after entering a keyword.

Refer to Editor&Terminal.txt in the scripting documentation for a full list of available shortcuts.

The other stuff you mentioned is a bit more tricky.

In general, there are no observables to keep track of changes happening at the file system level. We do have observables such as renoise.tool().app_new_document_observable (called whenever a new song is created, or an existing song is loaded) and renoise.tool().app_saved_document_observable, so your tool could listen to those and know when to check the song’s file name, path, etc., in order to update its internal state. More details in Renoise.ScriptingTool.API.lua

Anything related to the currently loaded song’s file name and path is pretty much read-only, and can only be changed indirectly by re-saving the song under a different file name and path.

You could in theory rename the XRNS file directly in the file system, but Renoise will not do anything special in response to this – your tool will still need to re-load the song from its new location. Take a look at Lua.Standard.API.lua to read about the various os.* functions you can use to access and manipulate files, directories, and so on.

There’s no default song path, so you’ll have to take care of this yourself, and prompt the user to define one when necessary. You can use renoise.app():prompt_for_path(dialog_title) to let the user pick a directory. More details in Renoise.Application.API.lua

Hey thanks dblue,

Some more questions:

  • do you think the r3 lua api provides all functions for loading a xrns song next to the current song, copying all fx from specified tracks to the current songs, also copying creating send tracks including fx and reconnect all stuff (send and meta) afterwards automatically like in the original song?

  • is it possible to create an event/observer on click on a custom menu or if menu is focussing in general?

Thx

Guys, can you gurus take a second of your time for my little 2 questions? Yes or no would be enough for me, I don’t expect you to list all needed functions.

Ah, and a third:

  • If it’s possible, should I wait until Renoise of 3.1, since a bunch will change in the API?

I thinkyou can have that xrns opening thing, will be hell of a project for you though, just open the xrns as a zip and see

The menu thing, no

only the devs can answer the latter and probably aren’t too sure themselves at the moment

I thinkyou can have that xrns opening thing, will be hell of a project for you though, just open the xrns as a zip and see

The menu thing, no

only the devs can answer the latter and probably aren’t too sure themselves at the moment

Oh ok, thought like accessing the second “virtual” song object using the normal song functions like "copy fx chain"etc, and not raw processing the xml data in the song :slight_smile:

  • do you think the r3 lua api provides all functions for loading a xrns song next to the current song (…)

The Lua API only provides methods for operating directly on the currently loaded song.

There’s no native method of loading an XRNS song into a temporary object, and then copying some of it contents to/from the currently loaded song. (This would of course be awesome, but it simply isn’t possible at this time.)

So pretty much anything you do here will be a hack, whether it’s somehow opening the XRNS ZIP archive and then reading the raw XML, or having Renoise load multiple different songs in series and performing operations back and forth with them, etc. There are ways to get it done, but they certainly won’t be pretty.

  • is it possible to create an event/observer on click on a custom menu or if menu is focussing in general?

Not exactly sure what you’re trying to do here, but if you’re using a custom popup menu (a dropdown) in your GUI, then you can attach a notifier that will fire when the selected item changes.

There’s no notifier to alert you when the popup is opened or focused.

See: Renoise.ViewBuilder.API.lua

  • If it’s possible, should I wait until Renoise of 3.1, since a bunch will change in the API?

We’re not talking about a huge change to the entire API here. There’ll likely be a few small tweaks necessary when moving your code from 3.0 to 3.1, but it shouldn’t require a major overhaul or rewrite.

@jurek: Honestly, processing the raw xml data, in something outside of renoise altogether (processing all that will be slow), seems much easier than using the internal copying functions, just look at thexrni-mergertool.

Ok guys, thanks lots for info.