Old 05-01-2021, 03:56 PM   #1
Kaxaze music
Human being with feelings
 
Kaxaze music's Avatar
 
Join Date: Sep 2020
Posts: 109
Default How to share a Custom action as a .lua file

I have read a lot of threads saying that the custom action are in the .ini thing and for cycle action too, but i just want to know where could i get the actual code of A CUSTOM ACTION of EITHER cycle action editor or action list.
Kaxaze music is online now   Reply With Quote
Old 05-01-2021, 04:07 PM   #2
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,288
Default

In general, these are three different topics:
  1. Custom Actions (for combining multiple Actions into a single Action): https://www.reaper.fm/videos.php#15Evzb7rWCo
  2. Cycle Actions (for creating a conditional or toggle Action): https://www.youtube.com/watch?v=VjWpQXSyaVY
  3. Scripts (e.g. lua) for more complex things that can't be done with Custom or Cycle Actions

For editing/viewing existing ones with the built-in editors:
  • Custom Action: Action List > Edit Action
  • Cycle Action: Extensions > Cycle Action Editor
  • Lua Scripts: Action List > Edit Action

For sharing:
  • Cycle Actions can be shared via the [Import/Export] button in the Cycle Action Editor (Extensions > Cycle Action Editor)
  • .ReaperKeyMap files for Custom Actions can be exported/imported via the [Key map] button in the Action List
  • Shared .lua script files can be imported into the Action List via click on the [New action] button and using the 'Load Reascript' option there

General side note: the dedicated section for script specific questions is located here: https://forum.cockos.com/forumdisplay.php?f=3


Quote:
Originally Posted by Kaxaze music View Post
How to share a Custom action as a .lua file
Quote:
Originally Posted by Kaxaze music View Post
...but i just want to know where could i get the actual code of A CUSTOM ACTION of EITHER cycle action editor or action list.
I'm not sure exactly what you mean with '... where could i get the actual code of ...'.
So if the info above doesn't answer your question or you're looking for something else, can you please post more details or an example of what you're trying to do.
__________________
ReaLauncher

Last edited by solger; 05-01-2021 at 04:46 PM. Reason: merged two posts into one
solger is offline   Reply With Quote
Old 05-02-2021, 03:14 AM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,132
Default

you can use Main_OnCommand by right click the action/script copy ID
the first line is a native action ID 41173
the second line is the ID of a custom Lua script
Just save them as a Lua script.
Code:
reaper.Main_OnCommand(41173, 0) -- Item navigation: Move cursor to start of items

commandID1 = reaper.NamedCommandLookup("_RSbe31a3de2526d47fa8357af06379275cceb291c2")
reaper.Main_OnCommand(commandID1, 0) -- Script: ReaTrak sections help.lua
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 05-02-2021, 07:31 AM   #4
valy
Human being with feelings
 
Join Date: Jan 2020
Posts: 1,922
Default

Quote:
Originally Posted by MusoBob View Post
you can use Main_OnCommand by right click the action/script copy ID
the first line is a native action ID 41173
the second line is the ID of a custom Lua script
Just save them as a Lua script.
Code:
reaper.Main_OnCommand(41173, 0) -- Item navigation: Move cursor to start of items

commandID1 = reaper.NamedCommandLookup("_RSbe31a3de2526d47fa8357af06379275cceb291c2")
reaper.Main_OnCommand(commandID1, 0) -- Script: ReaTrak sections help.lua
Do those values sometimes vary system to system, or am I thinking of something else?
valy is offline   Reply With Quote
Old 05-02-2021, 09:46 AM   #5
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,288
Default

Quote:
Originally Posted by valy View Post
Do those values sometimes vary system to system, or am I thinking of something else?
If I remember correctly:

The generated action command ID strings of (newly created or imported) scripts and Custom/Cycle Actions might vary on different Reaper installs:
Code:
commandID1 = reaper.NamedCommandLookup("_RSbe31a3de2526d47fa8357af06379275cceb291c2")
Command IDs of native Actions and command ID strings of SWS Actions should usually stay the same:
Code:
reaper.Main_OnCommand(41173, 0)
reaper.Main_OnCommand(reaper.NamedCommandLookup("_S&M_SHOW_RESOURCES_VIEW"), 0);
__________________
ReaLauncher

Last edited by solger; 05-02-2021 at 10:08 AM.
solger is offline   Reply With Quote
Old 05-02-2021, 02:21 PM   #6
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,132
Default

Here's the script
ReaTrak sections help.lua
this is the command ID
_RSbe31a3de2526d47fa8357af06379275cceb291c2
you should get the same.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 05-02-2021, 03:00 PM   #7
valy
Human being with feelings
 
Join Date: Jan 2020
Posts: 1,922
Default

Quote:
Originally Posted by solger View Post
If I remember correctly:

The generated action command ID strings of (newly created or imported) scripts and Custom/Cycle Actions might vary on different Reaper installs:
Code:
commandID1 = reaper.NamedCommandLookup("_RSbe31a3de2526d47fa8357af06379275cceb291c2")
Command IDs of native Actions and command ID strings of SWS Actions should usually stay the same:
Code:
reaper.Main_OnCommand(41173, 0)
reaper.Main_OnCommand(reaper.NamedCommandLookup("_S&M_SHOW_RESOURCES_VIEW"), 0);
Yeah, that's what I was thinking of, thanks.
valy is offline   Reply With Quote
Old 05-02-2021, 03:50 PM   #8
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,132
Default

What ID are you getting with the script I uploaded ?
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 05-02-2021, 04:32 PM   #9
valy
Human being with feelings
 
Join Date: Jan 2020
Posts: 1,922
Default

Quote:
Originally Posted by MusoBob View Post
What ID are you getting with the script I uploaded ?
_RS6f70fc7779cd65c5ba3ca093edee53c0f7bb98ed
valy is offline   Reply With Quote
Old 05-02-2021, 04:33 PM   #10
valy
Human being with feelings
 
Join Date: Jan 2020
Posts: 1,922
Default

I don't remember what causes it to vary, but I remember a thread about it
valy is offline   Reply With Quote
Old 05-02-2021, 05:23 PM   #11
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,132
Default

Well that's useless if it's not the same as I have scripts that call on other scripts.

There is a dofile that will run a script
Code:
dofile(reaper.GetResourcePath()..'/Scripts/ReaTrak sections help.lua')
or whatever folder the current script is in
Code:
dir = ({reaper.get_action_context()})[2]:match("^(.*[/\\])")

dofile(dir..'ReaTrak sections help.lua')
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com

Last edited by MusoBob; 05-02-2021 at 05:33 PM.
MusoBob is offline   Reply With Quote
Old 05-02-2021, 06:10 PM   #12
Kaxaze music
Human being with feelings
 
Kaxaze music's Avatar
 
Join Date: Sep 2020
Posts: 109
Default

this Seems better than the previous idea
Kaxaze music is online now   Reply With Quote
Old 05-02-2021, 06:23 PM   #13
valy
Human being with feelings
 
Join Date: Jan 2020
Posts: 1,922
Default

Quote:
Originally Posted by MusoBob View Post
Well that's useless if it's not the same as I have scripts that call on other scripts.

There is a dofile that will run a script
Code:
dofile(reaper.GetResourcePath()..'/Scripts/ReaTrak sections help.lua')
or whatever folder the current script is in
Code:
dir = ({reaper.get_action_context()})[2]:match("^(.*[/\\])")

dofile(dir..'ReaTrak sections help.lua')
Here's the thread I was thinking of:

https://forums.cockos.com/showthread.php?t=221328

Specifically, cfillion's post is informative:

Quote:
A ReaScript's command ID is deterministic. It's derived from the script's path and filename relative to the current install's resource directory's Scripts folder (if installed inside). Portable or regular install doesn't matter and editing the contents of a script doesn't affect the ID. As long as the relative path and filename is exactly the same, so should the command ID.*

*Some conditions apply. REAPER v5.1 or newer only. The full path must be under 260 characters in length on Windows.
valy is offline   Reply With Quote
Old 05-02-2021, 07:04 PM   #14
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,132
Default

Yes, it's all coming back to me now, that's why I told users to put the scripts in resource REAPER\Scripts\ReaTrak so they will have the same ID.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 05-03-2021, 08:57 AM   #15
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,288
Default

Quote:
Originally Posted by valy View Post
Here's the thread I was thinking of:

https://forums.cockos.com/showthread.php?t=221328

Specifically, cfillion's post is informative:
Thanks. Bookmarked for future reference
__________________
ReaLauncher
solger 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 10:51 PM.


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