|
|
|
08-14-2018, 10:21 AM
|
#1
|
Human being with feelings
Join Date: Dec 2012
Location: Raleigh, NC, USA
Posts: 405
|
LUA command terms?
With much appreciation to VanHaze, who got me to this point -
I have a script for mouse selection behavior, but it doesn't work because (presumably) I am using a Lenovo laptop touchpad. Are there touchpad-specific commands that can be edited in? I pasted the script below.
local window, segment, details = r.BR_GetMouseCursorContext()
local mouse = r.BR_GetMouseCursorContext_Position()
if not mouse then bla() return end
local mouse_tr = r.BR_TrackAtMouseCursor()
if not mouse_tr then bla() return end
local items = r.CountTrackMediaItems(mouse_tr)
local min_d = math.huge
local item_c
for i = 0, items - 1 do
local item = r.GetTrackMediaItem(mouse_tr,i)
local it_x = r.GetMediaItemInfo_Value(item, 'D_POSITION')
local it_y = r.GetMediaItemInfo_Value(item, 'D_LENGTH')+it_x
if it_x < mouse and it_y > mouse then
item_c = item
break
else
local min = math.min(math.abs(it_x-mouse),math.abs(it_y-mouse))
if min_d > min then
min_d = min
item_c = item
end
end
end
__________________
Jeffrey's REAPER tracks Are on Spotify as well as most other streaming services, under the name Karmic Cage.
|
|
|
08-14-2018, 10:43 AM
|
#2
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Quote:
doesn't work because (presumably) I am using a Lenovo laptop touchpad
|
It is just full of misundestandings of how REAPER API and lua itself works. What do you want to do?
|
|
|
08-14-2018, 10:50 AM
|
#3
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
What does "it doesn't work" mean. Does it display an error message or doesn't it do anything at all?
What is the script supposed to do in the first place and what do you mean by Lua command terms(as stated in the thread-title)?
Edit:
just one thing I noticed instantly:
Code:
if not mouse then bla() return end
can't work, as there is no function bla defined anywhere.
Another thing, please use the code-BB-codes for displaying source-codes, as this makes your code much more readable, and some comments, what the code is supposed to do at a given point(or what you think it should do, even if it doesn't)
Code:
local window, segment, details = r.BR_GetMouseCursorContext()
local mouse = r.BR_GetMouseCursorContext_Position()
if not mouse then
bla()
return
end
local mouse_tr = r.BR_TrackAtMouseCursor()
if not mouse_tr then
bla()
return
end
local items = r.CountTrackMediaItems(mouse_tr)
local min_d = math.huge
local item_c
for i = 0, items - 1 do
local item = r.GetTrackMediaItem(mouse_tr,i)
local it_x = r.GetMediaItemInfo_Value(item, 'D_POSITION')
local it_y = r.GetMediaItemInfo_Value(item, 'D_LENGTH')+it_x
if it_x < mouse and it_y > mouse then
item_c = item
break
else
local min = math.min(math.abs(it_x-mouse),math.abs(it_y-mouse))
if min_d > min then
min_d = min
item_c = item
end
end
end
Last edited by Meo-Ada Mespotine; 08-14-2018 at 10:59 AM.
|
|
|
08-14-2018, 11:02 AM
|
#4
|
Human being with feelings
Join Date: Dec 2012
Location: Raleigh, NC, USA
Posts: 405
|
It is supposed to allow your mouse to select the nearest object. By "doesn't work" I mean I get an error message referring to the first line with the 'MouseCursor' term, to the effect that it is a null quantity. Sorry I'm not a programmer, not familiar with precise terminology. I think perhaps there is a simple substitution edit that could make this script work with a touchpad instead.
__________________
Jeffrey's REAPER tracks Are on Spotify as well as most other streaming services, under the name Karmic Cage.
|
|
|
08-14-2018, 11:06 AM
|
#5
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Ok, as far as I can see, you use r. before all Reaper-Api-commands, but they must start with reaper. instead.
e.g.
r.BR_GetMouseCursorContext_Position()
must be
reaper.BR_GetMouseCursorContext_Position()
The same goes with all other functions, that start with r. just replace r. with reaper.
VanHaze probably showed you a way to use r. instead, but, especially if you are not programmer, please use the "official" way of doing it, which is shown in the Reascript-API-documentation.
Have you looked into the API-documentation?
Edit: as far as I can see, you don't need bla() in your script at all. What is your intention with bla() ?
|
|
|
08-14-2018, 11:24 AM
|
#6
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Quote:
Originally Posted by JeffreyET
allow your mouse to select the nearest object.
|
Here are some questions you should answer youself before asking us:
1) what is object - item, automation item, envelope point, stretch marker, midi note, etc?
2) is there a time limit for selection. Object to select may be placed 6 hours far from your mouse, and it will be selected since it nearest?
3) should it take into account other tracks?
4) deselect other stuff?
Btw what is wrong with your touchpad? I have Asus laptop and I use touchpad with no problems even on pretty complex projects.
|
|
|
08-14-2018, 11:34 AM
|
#7
|
Human being with feelings
Join Date: Dec 2012
Location: Raleigh, NC, USA
Posts: 405
|
Quote:
Originally Posted by mpl
Here are some questions you should answer youself before asking us:
1) what is object - item, automation item, envelope point, stretch marker, midi note, etc?
2) is there a time limit for selection. Object to select may be placed 6 hours far from your mouse, and it will be selected since it nearest?
3) should it take into account other tracks?
4) deselect other stuff?
Btw what is wrong with your touchpad? I have Asus laptop and I use touchpad with no problems even on pretty complex projects.
|
Nothing wrong, just want a way to select notes in the MIDI editor with less micro-precision hovering...
__________________
Jeffrey's REAPER tracks Are on Spotify as well as most other streaming services, under the name Karmic Cage.
|
|
|
08-14-2018, 11:40 AM
|
#8
|
Human being with feelings
Join Date: Dec 2012
Location: Raleigh, NC, USA
Posts: 405
|
Quote:
Originally Posted by mespotine
Ok, as far as I can see, you use r. before all Reaper-Api-commands, but they must start with reaper. instead.
e.g.
r.BR_GetMouseCursorContext_Position()
must be
reaper.BR_GetMouseCursorContext_Position()
The same goes with all other functions, that start with r. just replace r. with reaper.
VanHaze probably showed you a way to use r. instead, but, especially if you are not programmer, please use the "official" way of doing it, which is shown in the Reascript-API-documentation.
Have you looked into the API-documentation?
Edit: as far as I can see, you don't need bla() in your script at all. What is your intention with bla() ?
|
Don't know about bla(), I just took the script whole from someone else. Not interested or skilled in dissecting the code. But I'll try your simple suggestion before quietly leaving the arena
__________________
Jeffrey's REAPER tracks Are on Spotify as well as most other streaming services, under the name Karmic Cage.
|
|
|
08-14-2018, 11:49 AM
|
#9
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Ah, ok, that explains the difficulties in the script
|
|
|
08-14-2018, 12:02 PM
|
#10
|
Human being with feelings
Join Date: Dec 2012
Location: Raleigh, NC, USA
Posts: 405
|
Hey ya know what? There is already an action pre-written for this - I just didn't look for it. So I've been barking up a much bigger tree than I needed to be. Peace & thanks
__________________
Jeffrey's REAPER tracks Are on Spotify as well as most other streaming services, under the name Karmic Cage.
|
|
|
08-14-2018, 12:27 PM
|
#11
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Which action is it? Might be helpful for others searching the forum.
|
|
|
08-15-2018, 12:02 AM
|
#12
|
Human being with feelings
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
|
"Script: me2beats_Select only note near mouse.lua"
|
|
|
08-20-2018, 06:57 AM
|
#13
|
Human being with feelings
Join Date: Dec 2012
Location: Raleigh, NC, USA
Posts: 405
|
Mesopotine - I'm away from my computer, now, I'll look it up & post later...I looked for & found an action for selecting a note in the MIDI editor
__________________
Jeffrey's REAPER tracks Are on Spotify as well as most other streaming services, under the name Karmic Cage.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:44 PM.
|