Old 04-01-2020, 06:26 AM   #1
fbeauvaisc
Human being with feelings
 
Join Date: Nov 2018
Location: Montreal
Posts: 405
Default Script Edit

Hi,

I've got this script from another thread that makes my edit and play cursor follow mouse cursor but I can't make it obey snap by adding actions. It there a way to modify the script so it obeys snap?

function main()
reaper.BR_GetMouseCursorContext()
local pos = reaper.BR_GetMouseCursorContext_Position()
if pos > -1 then
reaper.SetEditCurPos2(0, pos, false, false)
end
reaper.defer(main)
end

function exit()
local is_new_value,filename,sectionID,cmdID,mode,resolut ion,val = reaper.get_action_context()
reaper.SetToggleCommandState(sectionID, cmdID, 0)
reaper.RefreshToolbar2(sectionID, cmdID)
end

local is_new_value,filename,sectionID,cmdID,mode,resolut ion,val = reaper.get_action_context()
reaper.SetToggleCommandState(sectionID, cmdID, 1)
reaper.RefreshToolbar2(sectionID, cmdID)

reaper.atexit(exit)

main()


Here's my custom action.

Action:Toggle arm of next action
Item: Split item at edit or play cursor
Script: Edit Cursor Follors Mouse Cursor.lua

Thanks,
fbeauvaisc is offline   Reply With Quote
Old 04-01-2020, 10:17 AM   #2
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by fbeauvaisc View Post
Hi,

I've got this script from another thread that makes my edit and play cursor follow mouse cursor but I can't make it obey snap by adding actions. It there a way to modify the script so it obeys snap?
How about,..
Code:
if pos > -1 then
  reaper.SetEditCurPos2(0, reaper.SnapToGrid(0, pos), false, false)
end
Seems to work OK here if snapping is enabled.

There is also, reaper.BR_GetClosestGridDivision (SWS), which supposedly works with or without snapping enabled.

Last edited by Edgemeal; 04-01-2020 at 10:29 AM.
Edgemeal is offline   Reply With Quote
Old 04-02-2020, 04:33 AM   #3
fbeauvaisc
Human being with feelings
 
Join Date: Nov 2018
Location: Montreal
Posts: 405
Default

Quote:
Originally Posted by Edgemeal View Post
How about,..
Code:
if pos > -1 then
  reaper.SetEditCurPos2(0, reaper.SnapToGrid(0, pos), false, false)
end
Seems to work OK here if snapping is enabled.

There is also, reaper.BR_GetClosestGridDivision (SWS), which supposedly works with or without snapping enabled.
Thanks! Works great!
fbeauvaisc 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:43 PM.


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