Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 06-14-2018, 10:23 AM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default API: Access to "ReaScript: Run reaScript (EEL, lua, or python)..."

Since some tasks are better suited for one scripting language over another (Lua for ease of writing and better GUI capabilities, EEL for audio processing, etc), it would be really handy if scripts of different languages could call each other just like a user clicking ReaScript: Run reaScript (EEL, lua, or python)... on their own.

At a basic level, it could look like:
Code:
--Lua script

reaper.SetExtState("my_script", "vars", "1,5,a")
reaper.RunReaScript("Scripts/my_other_script.eel")


-- EEL script (written as Lua because I suck at EEL)

vars = reaper.GetExtState("my_script", "vars")
retvals = do_some_complicated_audio_processing_using(vars)
reaper.SetExtState("my_script", "retvals", retvals)


--Lua script

reaper.defer(keep_checking_for_ExtState_retvals)
reaper.ShowConsoleMsg("Got the following retvals: " .. retvals)
Or, if some kind, generous, and sexy developer felt like it, passing arguments back and forth to avoid all the ExtState business:

Code:
--Lua script

local retvals = reaper.RunReaScript("my_other_script.eel", arg1, arg2, etc)
Cheers.
__________________
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
Old 06-14-2018, 10:28 AM   #2
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,175
Default

Quote:
Originally Posted by Lokasenna View Post

Or, if some kind, generous, and sexy developer felt like it, passing arguments back and forth to avoid all the ExtState business:

Code:
--Lua script

local retvals = reaper.RunReaScript("my_other_script.eel", arg1, arg2, etc)
This would be amazing!!
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 06-14-2018, 12:00 PM   #3
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,902
Default

+1. !!
X-Raym is offline   Reply With Quote
Old 06-15-2018, 06:22 AM   #4
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Yes please!!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 06-15-2018, 07:00 AM   #5
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

+1000
Especially the parameter/avoiding extstate-stuff

@lokasenna
Regarding your first FR, do you mean, mixture of several programming languages in one script, so ReaScript would treat the individual parts of the code as individual scripts during execution?
Meo-Ada Mespotine is offline   Reply With Quote
Old 06-15-2018, 07:33 AM   #6
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by mespotine View Post
+1000
Especially the parameter/avoiding extstate-stuff

@lokasenna
Regarding your first FR, do you mean, mixture of several programming languages in one script, so ReaScript would treat the individual parts of the code as individual scripts during execution?
Sort of - being able to call an EEL script from a Lua script. They would be completely separate processes, which we can already do manually:

- Run the Lua script
- Have it store some variables
- Use the action list to run the EEL script
- Have it load the variables and do stuff
- Have it save the returned value
- Have the Lua script waiting with a defer loop until it sees the returned value as an ExtState

At the moment we can do this via Main_OnCommand if the EEL script is registered as an action, whereas being able to call them directly would mean only your "main" script needs to show up. If a script had several different audio processing features written in EEL with a Lua frontend, direct access would be much simpler.
__________________
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
Old 10-27-2018, 05:11 PM   #7
tXShooter
Human being with feelings
 
tXShooter's Avatar
 
Join Date: Aug 2017
Posts: 336
Default

Quote:
Originally Posted by Lokasenna View Post
At the moment we can do this via Main_OnCommand if the ... script is registered as an action...
What's the difference between an Action ID and a Command ID?

How does one register a script as an action, and can that action be called from outside of Reaper, ... saaayyy Autohotkey, perhaps?
tXShooter is offline   Reply With Quote
Old 10-28-2018, 06:08 AM   #8
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
Default

Quote:
Originally Posted by tXShooter View Post
What's the difference between an Action ID and a Command ID?
A script is registered as an action when it's loaded in the Action List. Command is a synonym for action. But to answer your question: there are two kinds of command IDs. The built-in actions have a fixed numeric ID which can be directly used. Extension plugin, custom and script actions are identified by a "named command ID" (for scripts it's a hash derived from the path). These actions also have an underlying numeric ID but, because it's determined at runtime, it's not guaranteed to always be the same.

A named command ID must be converted to its current underlying numeric ID using NamedCommandLookup before being able to run the script using Main_OnCommand or an external program like AutoHotkey posting a WM_COMMAND message.

Last edited by cfillion; 10-28-2018 at 06:45 AM.
cfillion is offline   Reply With Quote
Old 10-28-2018, 09:37 AM   #9
tXShooter
Human being with feelings
 
tXShooter's Avatar
 
Join Date: Aug 2017
Posts: 336
Default

Quote:
Originally Posted by cfillion View Post
A named command ID must be converted to its current underlying numeric ID using NamedCommandLookup before being able to run the script using Main_OnCommand or an external program like AutoHotkey posting a WM_COMMAND message.
I'm guessing that when you say, "... because it's determined at runtime, it's not guaranteed to always be the same", that these Command ID's aren't dependable from one Reaper Session to the next?

In theory then, could one create a small script to output the list of Command ID's (via NamedCommandLoopkup to either console, clipboard, or file), and register that script to a hotkey, then have that hotkey activated by AHK? Then AHK could receive that information, and from that point any 'registered' scripts could be used externally and dependably (during that Reaper session only, of course).

Does that make sense and sound about right?
tXShooter is offline   Reply With Quote
Old 10-28-2018, 10:11 AM   #10
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,970
Default

Quote:
Originally Posted by tXShooter View Post
Does that make sense and sound about right?
That would work. Alternatively, if AHK supports making HTTP requests, you could use REAPER's web interface feature. It allows running actions from the main section directly using their named command IDs: /_/command-id-or-named-command-id-here.

Last edited by cfillion; 10-28-2018 at 10:20 AM.
cfillion is offline   Reply With Quote
Old 10-17-2021, 10:20 AM   #11
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,146
Default

Bump........
Buy One is offline   Reply With Quote
Old 07-04-2022, 03:09 PM   #12
Dex
Human being with feelings
 
Join Date: Sep 2017
Posts: 518
Default

+1
Dex is offline   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 05:40 PM.


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