/
TJF Paste Test.lua
133 lines (83 loc) · 3.15 KB
/
TJF Paste Test.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
--@noindex
-- NoIndex: true
--@description TJF Script Name
--@version 1.0
--@author Tim Farrell
--@links
-- TJF Reapack https://github.com/sonictim/TJF-Scripts/raw/master/index.xml
--
--@about
-- # TJF Script Name
--
-- Information about the script
--
--
-- DISCLAIMER:
-- This script was written for my own personal use and therefore I offer no support of any kind.
-- Any feature requests/bug reports will be ignored entirely, unless of course they interest me and I want to pursue them.
-- I strongly recommend never to run this or any other script I've written for any reason what so ever.
-- Ignore this advice at your own peril!
--
--
--@changelog
-- v1.0 - nothing to report
--[[------------------------------[[---
DEBUG
---]]------------------------------]]--
reaper.ClearConsole()
local function Msg(param) reaper.ShowConsoleMsg(tostring(param).."\n") end
local function GetItems(section)
local items = {}
items.Razor = reaper.GetExtState( section, "Razor Edits")
local key = 1
local loop = reaper.HasExtState(section, "Item" .. key)
while loop == true do
items[key] = reaper.GetExtState( section, "Item" .. key )
if items[key] == "nil" then items[key] = nil end
key = key + 1
loop = reaper.HasExtState(section, "Item" .. key)
end
return items
end
function GetCopyData()
local tracks = {}
local key = 1
local section = "Track" .. key
local loop = reaper.HasExtState(section, "Item1")
while loop == true do
table.insert(tracks, GetItems(section))
key = key + 1
section = "Track" .. key
loop = reaper.HasExtState(section, "Item1")
end
tracks.starttime = reaper.GetExtState( "TJF Copy", "StartTime" )
tracks.endtime = reaper.GetExtState( "TJF Copy", "endTime" )
return tracks
end
--[[------------------------------[[---
MAIN
---]]------------------------------]]--
local function Main()
track = GetCopyData()
local pdif = reaper.GetCursorPositionEx( 0 ) - track.starttime
--[[
for i = 1, #items do
local item = reaper.AddMediaItemToTrack( reaper.GetTrack(0,0) )
reaper.SetItemStateChunk( item, items[i], false )
local itemstart = reaper.GetMediaItemInfo_Value( item, "D_POSITION" )
reaper.SetMediaItemInfo_Value( item, "D_POSITION", itemstart + pdif )
end
]]
end--Main()
--[[------------------------------[[---
CALL THE SCRIPT
---]]------------------------------]]--
reaper.Undo_BeginBlock()
--reaper.PreventUIRefresh(1) -- uncomment only once script works
Main()
--reaper.PreventUIRefresh(-1) -- uncomment only once script works
reaper.UpdateArrange()
--reaper.UpdateTimeline()
--reaper.TrackList_AdjustWindows(0) -- Updates the window view (used when resizing tracks)
reaper.Undo_EndBlock("TJF Paste Test", -1)
--reaper.defer(function() end) --prevent Undo