Old 02-13-2019, 07:43 AM   #1
Human being with feelings
Join Date: Aug 2011
Posts: 215
Default Question on NamedCommandLookup

So i am doing a script wihch triggers other scripts using this function. If i want to share this master script with other people using other computers, will the master script find the other scripts being called?

I am asking this cause i am not really sure if the string you use as a parameter for this function (ex:"_113088d11ae641c193a2b7ede3041ad5" for a ReaScript) is different on every machine. On my mind, this is a string that gets autogenerated when you import the script on the Action list, so it could differ from computer to computer?

Perhaps i am just overthinking..
reapero is offline   Reply With Quote
Old 02-13-2019, 08:42 AM   #2
Human being with feelings
sai'ke's Avatar
Join Date: Aug 2009
Location: NL
Posts: 661

Bit messy, but this is what I use. Maybe someone else knows a more native way to do it

local function findCommandID(name)
  local commandID
  local lines = {}
  local fn = reaper.GetResourcePath() .. '/reaper-kb.ini'
  for line in io.lines(fn) do
    lines[#lines + 1] = line
  for i,v in pairs(lines) do
    if ( v:find(name, 1, true) ) then
      local startidx = v:find("RS", 1, true)
      local endidx = v:find(" ", startidx, true)
      commandID = (v:sub(startidx,endidx-1))
  if ( commandID ) then
    return "_" .. commandID

function seq:callScript(scriptName)
  if ( not scriptName ) then
    reaper.ShowMessageBox("Error callScript called without specifying a script", "Error", 0)

  local cmdID = findCommandID( scriptName )
  if ( cmdID ) then
    local cmd = reaper.NamedCommandLookup( cmdID )
    if ( cmd ) then
      reaper.Main_OnCommand(cmd, 0)
      reaper.ShowMessageBox("Failed to load script "..cmd, "Error", 0)
[Tracker Plugin: Thread|Github|Reapack] | [Routing Plugin: Thread|Reapack] | [Filther: Thread|Github|Reapack] | [More JSFX: Thread|Reapack]

Last edited by sai'ke; 02-13-2019 at 08:50 AM.
sai'ke is offline   Reply With Quote
Old 02-13-2019, 10:40 AM   #3
Human being with feelings
nofish's Avatar
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,060


(haven't verified this myself)
nofish is offline   Reply With Quote
Old 02-18-2019, 06:32 AM   #4
Human being with feelings
mespotine's Avatar
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,565

You could use AddRemoveReascript-function and pass to it the filename of the luascript. If the script exists, it will return the command-id of that script, regardless of its ActionCommandID(the cryptic string), if not installed, it returns 0 or something.
If the script is already installed, it has no negative effect.

Just use that command-id, or, if it's 0, return an errormessage, which script must be installed for your script to work.

The reason for not using the attempt provided by nofish and cfillion is, that you can setup your own ActionCommandID in the reaper-kb.ini. That means, you can replace the cryptic string with something of your own that's more easy to read.
Unfortunately, that means, that there's a small chance for the script being installed, but using another ActionCommandID.

I also saw you are referring to the ActionCommandID for Actions(not scripts, as they start with _RS), so you probably need to parse the reaper-kb.ini for the action to be there. And if the actions combined in them are the actions you want.

If not, errormessage, if yes, use as you want it.
The latter case is the more complicated one, as there's no way of getting the actions combined in an Action using Reaper's API, only for scripts you can use the AddRemoveReaScript.

Maybe I should come up with something for my API for that...
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635

Last edited by mespotine; 02-18-2019 at 06:53 AM.
mespotine 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 05:27 AM.

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