Old 02-08-2019, 05:06 AM   #1
SebyMusic
Human being with feelings
 
Join Date: Apr 2018
Posts: 83
Default Script for Searching 3rd Aux in project

Hi, I'm looking for a script function in lua that does that.
Search for the third track in my project that contain the word 'Aux' in its track name.
Then return me the track number of it.

So If I have 5 tracks containing the word Aux, it will only return me the third one

Tks for help
Seby
SebyMusic is offline   Reply With Quote
Old 02-08-2019, 08:52 AM   #2
SebyMusic
Human being with feelings
 
Join Date: Apr 2018
Posts: 83
Default

Quote:
Originally Posted by SebyMusic View Post
Hi, I'm looking for a script function in lua that does that.
Search for the third track in my project that contain the word 'Aux' in its track name.
Then return me the track number of it.

So If I have 5 tracks containing the word Aux, it will only return me the third one

Tks for help
Seby
Is it possible to fo that?
tks for your help
Seby
SebyMusic is offline   Reply With Quote
Old 02-08-2019, 09:46 AM   #3
SebyMusic
Human being with feelings
 
Join Date: Apr 2018
Posts: 83
Default

I found this on the forum, but it does not exactly what I'm searching for, but maybe it's a start..
tks again
Seby

function getTrackByName(name)
for trackIndex = 0, reaper.CountTracks(0) - 1 do
local track = reaper.GetTrack(0, trackIndex)
local ok, trackName = reaper.GetSetMediaTrackInfo_String(track, 'P_NAME', '', false)

if ok and trackName == name then
return track -- found it! stopping the search here
end
end
end

local track = getTrackByName("Structure")

if track then -- if a track named "Structure" was found
reaper.SetOnlyTrackSelected(track)
end
SebyMusic is offline   Reply With Quote
Old 02-08-2019, 12:42 PM   #4
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 960
Default

Honestly don't know lua string functions very well, but came up with this,
Code:
function getTrackByName(name, instance)
  name = string.lower(name)
  local counter = 0  
  for trackIndex = 0, reaper.CountTracks(0) - 1 do
    local track = reaper.GetTrack(0, trackIndex)
    local ok, trackName = reaper.GetSetMediaTrackInfo_String(track, 'P_NAME', '', false)
    if ok and string.find(string.lower(trackName),name) then
      counter = counter + 1
      if counter == instance then  -- found it! stopping the search here 
        return track
      end
    end
  end
end

 -- get 3rd track that contains word 'Aux' (non case sensitive)
local track = getTrackByName("Aux", 3)
if track then
  reaper.SetOnlyTrackSelected(track)
end
Edgemeal is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.