Prev Previous Post   Next Post Next
Old 04-28-2018, 06:44 PM   #11
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Hi cool. I rearranged it a small amount to get it closer to what you want, but it sounds like script was a compromise? If you want different priorities, and can't get it yourself, try to phrase a new pseudo code question.

Lua provides the following relational operators:
Code:
<   >   <=  >=  ==  ~=
All these operators always result in true or false.

You can use and,or,not in comparisons. Or you can nest "ifs" to an even greater depth than is present in the script you posted.
Code:
if (A > 0) and (not(B < A)) then
  if C ~= D then
    if (E > F) or (G <= H) then
etc...
That's not all there is to the discussion or anything, but enough to phrase your request, hopefully. Some things in Reaper can't be queried for a value...

You see the difference in using GetSet_LoopTimeRange()? The TWO values returned may be at the same time position and not at 0 if you snap the ends together with the mouse for example.

I use GetCursorContext2(). It tries to return most recent value if something other than track/item/envelope has focus. 0 for track, 1 for items, 2 for envelope.

Don't use NamedCommandLookup() for native REAPER actions.

Code:
-- cool.lua

start, ending = reaper.GetSet_LoopTimeRange( 0, 0, 0, 0, 0 )
--focus = reaper.GetCursorContext()
focus = reaper.GetCursorContext2(true) -- unlikely to get unknown(-1) when arrange not focused

if start == ending then
  reaper.Main_OnCommand(40697, 0)
else
  if focus == 1 then
    reaper.Main_OnCommand(40312, 0)
  elseif focus == 2 then
    reaper.Main_OnCommand(40089, 0)
  else -- alternatively -- elseif focus == 0 then
    reaper.Main_OnCommand(40005, 0) -- remove tracks
  end
end
FnA is offline   Reply With Quote
 

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 05:41 PM.


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