All supported languages allow you to use OnCommand API calls within scripts - in fact, most scripts I've come across contain one or more of them somewhere. I'd get used to using them in scripts to allow you options, even if the task you currently have in mind really is just an exercise to save fingerwork.
Custom Actions are always the best place to start. A lot of the time, it's already possible to do what you want natively or via whatever other Custom Actions you've downloaded.
They're essentially macros - the equivalent of chaining together a number of shortcut commands, just as you would with, say, a wordprocessor. If the job can be done like that - great. Even if you have to create your own chain of commands, worry no further.
But the day will come when you need more than just a single "Are you sure?" confirmation. You'll often need more than one confirmation or to get more detailed inputs from the user. You'll need to parse the inputs. You might need to check how many tracks or items are selected, what kind of data is on them, where you are on the timeline, etc. Or find certain tracks or items and read data from them or within their data files. Then you'll need to run certain actions on certain tracks or items and not others.
So at that stage you need to use and manipulate variables and arrays (tables in Lua) and decision branching, and that's scripting territory.
The custom action approach basically says: "hit this combination of keystrokes in this order." I'd describe it as "training REAPER to type".
The scripting approach says: "have a good look at what's going on and depending on what you find, hit some combination of keystrokes applied to chosen parts (or do all kinds of other devious things)." That's more like "teaching REAPER to solve a puzzle".
PS It's handy to right-click the menu bar in the Actions window and check the box "Show action IDs".
Last edited by Jason Lyon; 01-23-2018 at 05:30 AM.
|