Skip to content

Commit

Permalink
Release Insert new track (inherit color from parent) v1.0 (ReaTeam#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Landeplage authored and cfillion committed May 3, 2019
1 parent ada8512 commit af241d0
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- @description Insert new track (inherit color from parent)
-- @author Mordi
-- @version 1.0
-- @about
-- # Insert new track (inherit color from parent)
--
-- Uses reaper's native "Insert new track" action, and colors the new track based on its parent track. If the track has no parent, no color will be applied.

SCRIPT_NAME = "Insert new track (inherit color from parent)"

-- Message function
function Msg(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n")
end

-- Begin undo-block
reaper.Undo_BeginBlock2(0)

-- Add new track
reaper.Main_OnCommand(40001, 0)

-- Get number of selected tracks
selNum = reaper.CountSelectedTracks(0)

-- Loop through each selected track
for i = 1, selNum do

-- Get selected track
track = reaper.GetSelectedTrack(0, i-1)

-- Get parent track
parent = reaper.GetMediaTrackInfo_Value(track, "P_PARTRACK")

-- Skip if track has no parent
if parent ~= 0.0 then

-- Get color from parent track
color = reaper.GetTrackColor(parent)

-- Apply color to selected track
reaper.SetTrackColor(track, color)

end
end

-- End undo-block
reaper.Undo_EndBlock2(0,SCRIPT_NAME,-1)

0 comments on commit af241d0

Please sign in to comment.