View Single Post
Old 07-11-2019, 09:05 PM   #11
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

thanks, dafarkias, but i think i want something much simpler as a standalone that i can add together with other simple actions to make a custom action. i appreciate your asking, though.

thanks, x. this appears to work on all track. i was looking for something that would work on a single selected track. i was planning on combining it with actions to:

1. unselect all tracks
2. select a specific track, in my case 3
3. this script

i did find a script from Archie that i was able to make some changes to and have gotten to work. it needs work but as a preliminary test it does work.
Code:
    -----------------------------------------------------------------------------
    local function No_Undo()end; local function no_undo()reaper.defer(No_Undo)end
    -----------------------------------------------------------------------------
     
    local SelTrack = reaper.GetSelectedTrack( 0, 0 )
    if not SelTrack then no_undo() return end
    
    local CountTrItem = reaper.CountTrackMediaItems( SelTrack )
    if CountTrItem > 0 then
        local Name = "test"
        for i = 1,CountTrItem do 
            local Tr_item =  reaper.GetTrackMediaItem( SelTrack, i-1 )
            local Take = reaper.GetActiveTake( Tr_item )
            if Take ~= nil then
              local Take_Name = reaper.GetTakeName( Take )
            
              if Take_Name == Name then
                  reaper.SelectAllMediaItems( 0, 0 )
                  reaper.SetMediaItemSelected( Tr_item, 1 )
                  undo = 1
                  break
              end
            end       
        end
    end 
    
    if undo == 1 then 
        reaper.Undo_BeginBlock()   
        reaper.Undo_EndBlock( [[Select first item from cursor
                             position in first selected track]],-1)
    else   
        no_undo()
    end
since this is intended to work with a template and stock items, the item names would be standardized and i thought i would hard-code them into the script. here it's just called 'test' but i thought i would make a new script for each of the roughly 20 stock items, each with its own name coded in. it will make things much faster in this context than having to take user input each time the stock item is sought. i do want to make a version that asks for user input but just as a variation.

maybe someone could confirm that i haven't done anything horrible in the changes?

thanks,
babag

Last edited by babag; 07-11-2019 at 09:16 PM.
babag is offline   Reply With Quote