forked from ReaTeam/ReaScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Insert new track (inherit color from parent) v1.0 (ReaTeam#182)
- Loading branch information
1 parent
ada8512
commit af241d0
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Tracks Properties/Mordi_Insert new track (inherit color from parent).lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |