From 9268eba19b5a8a3c9bb9fc52fc03da1ea0390e04 Mon Sep 17 00:00:00 2001 From: jmieszkowski <44314566+jmieszkowski@users.noreply.github.com> Date: Mon, 11 Feb 2019 23:20:14 +0100 Subject: [PATCH] Release Set the color of selected tracks from their parent tracks v1.0 (#155) --- ...lected tracks from their parent tracks.lua | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Tracks Properties/jmieszkowski_Set the color of selected tracks from their parent tracks.lua diff --git a/Tracks Properties/jmieszkowski_Set the color of selected tracks from their parent tracks.lua b/Tracks Properties/jmieszkowski_Set the color of selected tracks from their parent tracks.lua new file mode 100644 index 000000000..f9d945432 --- /dev/null +++ b/Tracks Properties/jmieszkowski_Set the color of selected tracks from their parent tracks.lua @@ -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()