Files
/
Amely Suncroll Auto Aim Midi R (Lite).lua
Latest commit
76 lines (59 loc) · 1.77 KB
/
Amely Suncroll Auto Aim Midi R (Lite).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
function MoveEditCursorToEndOfSelectedMIDIEvents()
local midiEditor = reaper.MIDIEditor_GetActive()
if not midiEditor then
return
end
local take = reaper.MIDIEditor_GetTake(midiEditor)
if not take or not reaper.TakeIsMIDI(take) then
return
end
local noteSelected = false
local _, notecnt = reaper.MIDI_CountEvts(take)
for i = 0, notecnt - 1 do
local _, selected = reaper.MIDI_GetNote(take, i)
if selected then
noteSelected = true
break
end
end
if noteSelected then
local commandId = 40873
reaper.MIDIEditor_LastFocused_OnCommand(commandId, false)
end
end
local script_identifier = "_MyScriptToggle"
local function IsScriptToggledOn()
return reaper.GetExtState(script_identifier, "Running") == "1"
end
local function SetScriptToggle(state)
if state then
reaper.SetExtState(script_identifier, "Running", "1", false)
else
reaper.DeleteExtState(script_identifier, "Running", false)
end
end
local last_time = reaper.time_precise()
function Main()
local current_time = reaper.time_precise()
if current_time - last_time >= 0.5 then
MoveEditCursorToEndOfSelectedMIDIEvents()
last_time = current_time
end
if IsScriptToggledOn() then
reaper.defer(Main)
else
Exit()
end
end
function Exit()
reaper.MB("Script terminated", "Auto Aim Midi R (Amely Suncroll)", 0)
SetScriptToggle(false)
end
if not IsScriptToggledOn() then
reaper.MB("Script working", "Auto Aim Midi R (Amely Suncroll)", 0)
SetScriptToggle(true)
reaper.defer(Main)
else
Exit()
end
reaper.atexit(Exit)