forked from ReaTeam/ReaScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLokasenna_Select tracks in selection with no items.lua
60 lines (39 loc) · 1.23 KB
/
Lokasenna_Select tracks in selection with no items.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--[[
Description: Select tracks in selection with no items
Version: 1.00
Author: Lokasenna
Donation: https://paypal.me/Lokasenna
Changelog:
Initial release
Links:
Lokasenna's Website http://forum.cockos.com/member.php?u=10417
About:
Extends the behavior of "Xenakios/SWS: Select tracks with no items"
to only look within the currently selected tracks
--]]
-- Licensed under the GNU GPL v3
local function Main()
local new_sel = {}
-- Get number of selected tracks
local num_sel = reaper.CountSelectedTracks(0)
if num_sel == 0 then return end
reaper.PreventUIRefresh(1)
-- For each selected track
for i = 1, num_sel do
local track = reaper.GetSelectedTrack(0, i - 1)
-- If it's empty..
if reaper.CountTrackMediaItems(track) == 0 then
-- Add to new_sel
new_sel[#new_sel + 1] = track
end
end
-- Deselect all tracks
reaper.Main_OnCommand(40297, 0)
-- Select tracks in new_sel
for k, tr in pairs(new_sel) do
reaper.SetTrackSelected(tr, true)
end
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
end
Main()