Old 04-26-2020, 02:06 PM   #1
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 532
Default reaper.MainOnCommand() shortcut

What do you guys think about this simple function?

Code:
local function rprMain(cmdid) 
	if type(cmdid) == "string" then
		cmdid = reaper.NamedCommandLookup(cmdid)
	end
	reaper.Main_OnCommand(cmdid, 0) 
end
It speeds up coding, supports non native CommandIDs and from what I understood, it speeds up lua as well? Making the MainOnCommand in a function?

Simply called by:
Code:
rprMain(1016) -- Transport Stop
or a SWS action like this:
Code:
rprMain("_SWS_AWCOUNTPLAYOFF") -- Disable CountIn
I'm thinking about starting to use it in my scripts. But I need the advice of professionals.
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is online now   Reply With Quote
Old 04-26-2020, 02:53 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 3,193
Default

NamedCommandLookup accepts integers as input too, so it can be simplified into:

Code:
local function rprMain(cmdid, flags) 
  cmdid = reaper.NamedCommandLookup(cmdid)
  reaper.Main_OnCommand(cmdid, flags or 0) 
end
cfillion is offline   Reply With Quote
Old 04-26-2020, 04:06 PM   #3
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: Apr 2020
Location: Leipzig
Posts: 639
Default

Done already in Ultraschall-API ^^

https://mespotin.uber.space/Ultrasch...tml#RunCommand
__________________
Use you/she/her, when contacting me, please. Thanks :) Not mentoring via PMs, sorry.
Ultraschall-API - 1200 ReaScript functions for Reaper - Reaper Internals - Developerdocs4Reaper - Donate, if you wish
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-26-2020, 04:28 PM   #4
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 532
Default

You guys will never cease to amaze me...

Thanks!
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is online now   Reply With Quote
Reply

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 03:51 PM.


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