View Single Post
Old 03-02-2017, 08:20 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

For custom actions and scripts you need to get action ID that Reaper has the script's GUID - "_ah4wp93pa98uf1awhatever" assigned to.

This is how I do it in Lua, along with some error checking:
Code:
-- 'act' is the action/script ID in a string

-- Scripts and custom actions all use the same format for their GUID,
-- so you just need to see if the string starts with a '_'
if string.sub(act, 1, 1) == "_" then
  act = reaper.NamedCommandLookup(act) 
end


-- Not strictly necessary, but Lua doesn't always like it when you try
-- to use a string as a number
act = tonumber(act)

-- Make sure that: 
-- a) tonumber() worked, and 
-- b) we have a useable action ID
if act and act > 0 then 
  reaper.Main_OnCommand(act, 0) 
end
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote