Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER General Discussion Forum

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 12-10-2019, 10:59 AM   #1
n997
Human being with feelings
 
Join Date: Dec 2018
Posts: 84
Default Do you use conditional/smart scripts for basic commands?

Sorry if this has been discussed already. Also apologies if you think this thread belongs to scripting section - I intentionally started it in General forum because it might be useful for people who aren't - yet - into scripting.


As I was customizing my REAPER setup, there was a need for basic editing commands to be more context-sensitive: same shortcut/context menu command initiating different actions depending on whether time selection was active, or item was selected, and so on.

I've now got many elementary actions such as COPY, CUT, DELETE, SPLIT, LOOP etc. linked to very basic conditional scripts, for example like this one for looping item or time selection:



Code:
reaper.PreventUIRefresh(1)

local starttime, endtime = reaper.GetSet_LoopTimeRange2(0, false, false, 0, 0, false)

-----------------------
-- if time NOT selected
-----------------------
if  starttime == endtime 
then

	item = reaper.GetSelectedMediaItem(0,0)
	if item ~= nil
	then

		reaper.Main_OnCommand(41039, 0) -- "Loop points: Set loop points to items"
		reaper.Main_OnCommand(40632, 0) -- "Go to start of loop"
		reaper.GetSetRepeat(1)
	
	end

end

-----------------------
-- if time IS selected 
-----------------------
if  starttime ~= endtime
then

	reaper.Main_OnCommand(40622, 0) -- "Time selection: Copy time selection to loop points"
	reaper.Main_OnCommand(40632, 0) -- "Go to start of loop"
	reaper.GetSetRepeat(1)

end


reaper.PreventUIRefresh(-1)
reaper.UpdateTimeline()

My questions for more experienced REAPER scripters is - do you use anything like this in your personal setups?
And is there perhaps already a better way to do things like this?



Generally, I was thinking that basic scripting like this might be part of the solution for users who are dissatisfied with REAPER's default user experience, or want it to resemble another DAW. At least, this possibility is something that newcomers should be made more aware of, as it does a lot to tailor the UX to suit one's needs.
But then again, I might just be reinventing the wheel here, so do tell if you have an opinion or insight on this subject

Last edited by n997; 12-11-2019 at 04:58 AM. Reason: told better what the script does
n997 is offline   Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.