Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 11-22-2020, 07:21 PM   #1
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default Testing if script is executing inside of compound custom action

Is there some way to test programmatically inside of a ReaScript to see if that ReaScript is executing inside a compound custom action?

In other words, lets say I have:

Action 1 (lua script)
Action 2 (lua script)
Action 3 (lua script)
And then I create a compound custom action
BigAction which executes Action 1; Action 2; Action 3
Is there any lua code I can write inside of Action 1, 2 or 3 to test to see if they are being executed as part of BigAction or just by themselves?

When I run run reaper.get_action_context within those Action 1, 2, 3, it tells me that the context is Action 1, 2, 3 no matter what.

How can I find out if I am running inside of BigAction?
cohler is offline   Reply With Quote
Old 11-22-2020, 09:07 PM   #2
juan_r
Human being with feelings
 
juan_r's Avatar
 
Join Date: Oct 2019
Posts: 1,082
Default

I'm no Lua expert, so I don't know about its scoping rules, but a global variable could possibly solve your problem.
juan_r is offline   Reply With Quote
Old 11-22-2020, 09:33 PM   #3
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juan_r View Post
I'm no Lua expert, so I don't know about its scoping rules, but a global variable could possibly solve your problem.
No. Global variables only exist within each lua script while they are executing. They don't continue to exist from script to script.
cohler is offline   Reply With Quote
Old 11-23-2020, 12:48 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

This variable could be saved as ProjExtState at start of the custom action. This would be a one line custom script.


Your script will then check this value at init.
X-Raym is offline   Reply With Quote
Old 11-23-2020, 01:00 PM   #5
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by X-Raym View Post
This variable could be saved as ProjExtState at start of the custom action. This would be a one line custom script.


Your script will then check this value at init.
Yeah, that's the only solution I have come up with so far. Specifically, I created a separate action which I include in the group action as the first action, and it saves a semaphor to memory rather than disk using SetExtState and then the internal actions can check that semaphor using GetExtState.

But it seems like there should be a builtin REAPER capability for doing that don't you think?
cohler is offline   Reply With Quote
Old 11-24-2020, 03:48 PM   #6
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I also asked this question some time ago, but unfortunately there doesn't seem to be an easy solution: Reascripts inside custom actions: Get custom action context and steps?.
juliansader is offline   Reply With Quote
Old 11-24-2020, 04:53 PM   #7
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
I also asked this question some time ago, but unfortunately there doesn't seem to be an easy solution: Reascripts inside custom actions: Get custom action context and steps?.
Yup. Thanks for the reference. This should clearly be a fundamental capability.
cohler 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 08:35 PM.


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