Old 02-07-2020, 07:35 AM   #1
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default connect 2 actions in one script

Hello
How can I connect this two actions?

action(41305)Item edit: Trim left edge of item to edit cursor
only left of the middle of the selected item

action(41311)Item edit: Trim right edge of item to edit cursor
only right of the middle of the selected item

Code:
--     curpos = reaper.GetCursorPosition()
--  start_pos = reaper.GetMediaItemInfo_Value(it, 'D_POSITION')
--        len = reaper.GetMediaItemInfo_Value(it, 'D_LENGTH')
--     curmid = start_pos + len/2
       
if curpos<curmid then
    --Item edit: Trim left edge of item to edit cursor
      reaper.Main_OnCommand(41305,1)
else
    --Item edit: Trim right edge of item to edit cursor  
      reaper.Main_OnCommand(41311,1)
Thank you very much

Last edited by Dragonetti; 02-07-2020 at 07:40 AM.
Dragonetti is offline   Reply With Quote
Old 02-07-2020, 09:17 AM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Like this?

Code:
it =  reaper.GetSelectedMediaItem(0, 0) -- get first sel. item
if it == nil then return end
curpos = reaper.GetCursorPosition()
start_pos = reaper.GetMediaItemInfo_Value(it, 'D_POSITION')
len = start_pos + reaper.GetMediaItemInfo_Value(it, 'D_LENGTH')
curmid = start_pos + len/2
       
if curpos<curmid then
    --Item edit: Trim left edge of item to edit cursor
      reaper.Main_OnCommand(41305,1)
else
    --Item edit: Trim right edge of item to edit cursor  
      reaper.Main_OnCommand(41311,1)
end
nofish is offline   Reply With Quote
Old 02-07-2020, 11:18 AM   #3
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

very fast
thank you
but len = only length
Code:
it =  reaper.GetSelectedMediaItem(0, 0) -- get first sel. item
if it == nil then return end
curpos = reaper.GetCursorPosition()
start_pos = reaper.GetMediaItemInfo_Value(it, 'D_POSITION')
len = reaper.GetMediaItemInfo_Value(it, 'D_LENGTH')
curmid = start_pos + len/2
       
if curpos<curmid then
    --Item edit: Trim left edge of item to edit cursor
      reaper.Main_OnCommand(41305,1)
else
    --Item edit: Trim right edge of item to edit cursor  
      reaper.Main_OnCommand(41311,1)
end
Dragonetti is offline   Reply With Quote
Old 02-07-2020, 11:52 AM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Ah right, sorry.
Donation received, thanks a lot.
nofish is offline   Reply With Quote
Old 02-08-2020, 03:57 AM   #5
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Is there a way to get this script toggle state (on/off)?
Dragonetti is offline   Reply With Quote
Old 02-08-2020, 01:22 PM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Get the toggle-state:
https://mespotin.uber.space/Ultrasch...leCommandState

Set the toggle-state:
https://mespotin.uber.space/Ultrasch...leCommandState
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 02-10-2020, 09:23 AM   #7
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by Dragonetti View Post
Is there a way to get this script toggle state (on/off)?
As this script is not one which continously runs in the background (so it can be toggled on/off), I don't understand what you mean by on/off, could you elaborate?
nofish 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 03:26 AM.


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