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 Set the color of selected tracks from their parent tracks v1.0 (
- Loading branch information
1 parent
e1c6130
commit 9268eba
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Tracks Properties/jmieszkowski_Set the color of selected tracks from their parent tracks.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,44 @@ | ||
-- @description Set the color of selected tracks from their parent tracks | ||
-- @author jmieszkowski | ||
-- @version 1.0 | ||
-- @link https://github.com/jmieszkowski/ReaScripts | ||
-- @about | ||
-- # Set the color of selected tracks from their parent track | ||
-- This script colors selected tracks according to their parents color | ||
-- How to use: > Select tracks that you want to color > Run the script | ||
|
||
function Main() | ||
number = getNumberOfSelectedTracks() | ||
local i = 0 | ||
while i ~= number do | ||
track = getTrack(i) | ||
folder_info = getFolderInfo(track) | ||
parent_track = getParentTrack() | ||
|
||
if parent_track ~= nil then -- check if track has a parent track, otherwise it would throw an error | ||
color = reaper.GetTrackColor(parent_track) | ||
|
||
if color ~= 0 then | ||
reaper.SetTrackColor(track,color) | ||
end | ||
end | ||
i = i+ 1 | ||
end | ||
end | ||
|
||
function getNumberOfSelectedTracks() | ||
return reaper.CountSelectedTracks(0) | ||
end | ||
|
||
function getTrack(i) | ||
return reaper.GetSelectedTrack(0,i) | ||
end | ||
|
||
function getFolderInfo(track) | ||
return reaper.GetMediaTrackInfo_Value(track, 'I_FOLDERDEPTH') | ||
end | ||
|
||
function getParentTrack() | ||
return reaper.GetParentTrack(track) | ||
end | ||
Main() |