Old 06-13-2021, 02:04 PM   #1
TRec
Human being with feelings
 
Join Date: Sep 2020
Posts: 8
Default Need help with lua code

So I'm trying to write a script that lets me convert a stereo item to mono using a script instead of the right click menu.

It works when when the item is clicked, but if the item is selected with the marquee tool or the current selected track is different from the track the item is on it doesn't work.

Here's the code:

function main()

reaper.Main_OnCommandEx(40894, 0, 0) -- Item: Explode multichannel audio or MIDI to new one-channel items
reaper.Main_OnCommandEx(40006, 0, 0) -- Item: Remove items
reaper.Main_OnCommandEx(41140, 0, 0) -- Item navigation: Select and move to item in next track without changing track selection
reaper.Main_OnCommandEx(40117, 0, 0) -- Options: Toggle trim content behind media items when editing
reaper.Main_OnCommandEx(41140, 0, 0) -- Item navigation: Select and move to item in next track without changing track selection
reaper.Main_OnCommandEx(40006, 0, 0) -- Item: Remove items
reaper.Main_OnCommandEx(40285, 0, 0) -- Track: Go to next track
reaper.Main_OnCommandEx(40287, 0, 0) -- Track: Go to next track (leaving other tracks selected)
reaper.Main_OnCommandEx(40288, 0, 0) -- Track: Go to previous track (leaving other tracks selected)
reaper.Main_OnCommandEx(40005, 0, 0) -- Track: Remove tracks


end

main()

Any help is appreciated, Thanks

Last edited by TRec; 06-13-2021 at 02:05 PM. Reason: Wanted to add the last line
TRec is offline   Reply With Quote
Old 06-17-2021, 12:59 AM   #2
xpander
Human being with feelings
 
xpander's Avatar
 
Join Date: Jun 2007
Location: Terra incognita
Posts: 7,670
Default

Quote:
Originally Posted by TRec View Post
It works when when the item is clicked, but if the item is selected with the marquee tool or the current selected track is different from the track the item is on it doesn't work.
Your script relies on track and item selections, so you must make sure you have both selected correctly. Marquee selecting items doesn't select the given tracks, that might be your problem.
xpander is offline   Reply With Quote
Old 06-20-2022, 01:38 AM   #3
TRec
Human being with feelings
 
Join Date: Sep 2020
Posts: 8
Default Thanks

Hi,

thanks that makes much more sense now
TRec 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:34 AM.


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