Reaper-Scripts/4PointCutting/4Pcut_select_src-tracks.lua

34 lines
1.2 KiB
Lua

-- Reaper Scripts for 4 point editing. This script selects the previous set source tracks
-- Author: Ludwig Frühschütz
-- Source: https://www.eleton-audio.de
-- Git: https://files.eleton-audio.de/gitea/Ludwig/Reaper-Scripts.git
-- License: GPL v3.0
-- Requires: Reaper 5 or 6
-- Requires: This script goes with several other scripts that work closely together.
-- Send a message to the console
function msg(m)
reaper.ShowConsoleMsg(tostring(m) .. "\n")
end
-- START HERE vvvvvvvvvvvvvvvvv
local tracks_str = ''
local tracks = {}
local retval
-- get stored GUIDs from rpp and select the tracks
retval, tracks_str = reaper.GetProjExtState(0, '4PointCut', 'src_tracks')
if retval > 0 then -- variable exists in rpp
-- separate GUIDs and populate track table
for str in string.gmatch(tracks_str, "([^"..'{'.."]+)") do
table.insert(tracks, reaper.BR_GetMediaTrackByGUID(0, '{' .. str))
end
-- select tracks
reaper.Main_OnCommand(40297, 0) -- Unselect all tracks
for _, track in ipairs(tracks) do
reaper.SetTrackSelected(track, true)
end
else
reaper.ClearConsole()
msg('Source tracks not specified, using all tracks as default!')
end