|
|
|
07-18-2018, 09:30 AM
|
#1
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Do something while in time selection - LUA [SOLVED]
Ok, it's time again - I smack my head against wall again.
I am writing a Reascript there I want something to be done
while the selected envelope point is inside of time selection.
This time I have no clue about how to do this - any help is welcome!
(Have checked the API but cant find anything, probably searching for wrong thing)
Code:
Pseudocode:
While (selected_point is inside timeselection) do
reaper.ShowConsoleMsg("You are still inside time selection")
else
reaper.ShowConsoleMsg("You are outside the time selection you naughty little boy!")
Last edited by tompad; 07-20-2018 at 09:36 AM.
|
|
|
07-18-2018, 09:37 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
You can use reaper.defer to check whether the given point is in the time selection 30 times per second (more or less). You can find the selected point with GetEnvelopePointEx.
Code:
pointPos = 3.1416
function testPointPos()
local startPos, endPos = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
if startPos <= pointPos and endPos >= pointPos then
reaper.ShowConsoleMsg("inside!\n")
else
reaper.ShowConsolemsg("outside!\n")
end
reaper.defer(testPointPos) -- recheck later
end
testPointPos()
|
|
|
07-19-2018, 04:58 AM
|
#3
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Quote:
Originally Posted by cfillion
You can use reaper.defer to check whether the given point is in the time selection 30 times per second (more or less). You can find the selected point with GetEnvelopePointEx.
|
Great! Thanks Cfillion!
I guess the reaper.defer is only needed if I want to run my script
in the background? I tried with GetSet_LoopTimeRange and the if-statement
and it all worked well (no need to run script in background - yet).
|
|
|
07-19-2018, 06:59 AM
|
#4
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by tompad
I guess the reaper.defer is only needed if I want to run my script in the background?
|
Exactly. I thought this was what you wanted to do (check points while the user changes the time selection).
|
|
|
07-19-2018, 07:34 AM
|
#5
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Quote:
Originally Posted by cfillion
Exactly. I thought this was what you wanted to do (check points while the user changes the time selection).
|
No I only needed the "startPos, endPos = reaper.GetSet_LoopTimeRange"-part.
I searched and searched and searched the API with wrong search words....
sometime its hard to find the proper search words. ;-)
Thanks again - with your help I just finished my first Reascript!
Its an "hybrid" with both lua-code and native actions.
|
|
|
07-20-2018, 06:26 AM
|
#6
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Hi again!
I checked the "reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)" in API list
and I dont get it - how can parameter 3 and 4 be 0??
Shouldn't it be the start and end of selection?
I know it works with 0 and 0, but why/how? It puzzle me....
|
|
|
07-20-2018, 06:34 AM
|
#7
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
It's a quirk - the same API functions are exposed to Lua, EEL, and Python, so most of them are designed to work for all three. Not sure about Python, but EEL takes the "returned" values as function arguments (might just be for functions with multiple return values).
In Lua we can do:
Code:
a, b, c = getvalues()
but EEL would be:
Code:
getvalues(a, b, c);
In this case, since you're using Lua, it doesn't matter what you specify for those values. They just have to be there (mostly*), and have to be of the correct type (integer, boolean, string).
* Some of the API functions don't seem to care. GetTrackName expects a string, for instance, but works fine if you don't provide it. When in doubt, you can always try calling the function with an argument set to nil and see if it gives you an error.
|
|
|
07-20-2018, 06:40 AM
|
#8
|
Human being with feelings
Join Date: May 2006
Location: Surrey, UK
Posts: 19,677
|
^^^
As the documentation is short, it would be clearer if it read:
Quote:
Lua: number start, number end = reaper.GetSet_LoopTimeRange(boolean isSet, boolean isLoop, 0, 0, boolean allowautoseek)
|
rather than
Quote:
Lua: number start, number end = reaper.GetSet_LoopTimeRange(boolean isSet, boolean isLoop, number start, number end, boolean allowautoseek)
|
__________________
DarkStar ... interesting, if true. . . . Inspired by ...
|
|
|
07-20-2018, 06:44 AM
|
#9
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by tompad
how can parameter 3 and 4 be 0??
|
They are ignored because isSet=false (the first parameter). They would be used to modify the time selection if isSet was true.
|
|
|
07-20-2018, 07:11 AM
|
#10
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by DarkStar
^^^
As the documentation is short, it would be clearer if it read:
rather than
|
There are a number of places where language-specific documentation would be helpful. Not holding my breath though.
This is Reaper - the forum IS the documentation.
|
|
|
07-20-2018, 09:32 AM
|
#11
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by Lokasenna
This is Reaper - the forum IS the documentation.
|
I'll print that quote on a T-Shirt
@tompad
Could you elaborate much further, what you can do with the selected envelope-point?
Do you want it to be moveable or just
1) I click a point as selected,
2) I run the script
3) it writes into the console, whether the selected envelope-point is within time-selection or not
Another thing is: you can have multiple envelope-points selected at the same time, where some may be within the time-selection and some not. This could be a problem, as far as I understood your post...
|
|
|
07-20-2018, 09:40 AM
|
#12
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Quote:
Originally Posted by cfillion
They are ignored because isSet=false (the first parameter). They would be used to modify the time selection if isSet was true.
|
Ahaaaa... now I understand!
@cfillion and @Lokassena - thanks for all the help, must ask - are you programmers in every day work?
|
|
|
07-20-2018, 09:45 AM
|
#13
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
Quote:
Originally Posted by mespotine
I'll print that quote on a T-Shirt
@tompad
Could you elaborate much further, what you can do with the selected envelope-point?
Do you want it to be moveable or just
1) I click a point as selected,
2) I run the script
3) it writes into the console, whether the selected envelope-point is within time-selection or not
Another thing is: you can have multiple envelope-points selected at the same time, where some may be within the time-selection and some not. This could be a problem, as far as I understood your post...
|
Hi mespotine!
I was just doing a simple script that randomly was putting points in the volume envelope, and I wanted it to stop doing it outside the time selection. No fancy thing - just my first script built with actions and some lua-code.
|
|
|
07-20-2018, 10:12 AM
|
#14
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by tompad
Ahaaaa... now I understand!
@cfillion and @Lokassena - thanks for all the help, must ask - are you programmers in every day work?
|
I wish. Unemployed electrician.
|
|
|
07-20-2018, 11:07 PM
|
#15
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
Quote:
Originally Posted by tompad
@cfillion and @Lokassena - thanks for all the help, must ask - are you programmers in every day work?
|
I'm not a programmer either.
|
|
|
07-21-2018, 03:04 PM
|
#16
|
Human being with feelings
Join Date: Jan 2010
Location: Fjugesta, Sweden
Posts: 811
|
@cfillion and @Lokassena
Are you sure? ;-) ....I mean, you both have made fantastic things
for Reaper (Reapack,GUI-library, Interactive Reascript, Radial Menu etc,etc)
Kudos to you!
|
|
|
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:29 AM.
|