Last updated:

ReaScript Video Tutorial — Part. 5: Conditions Basics

Conditions is the starting point of building useful scripts. Here are the basics on this subject !

Disclaimer
Since REAPER RC 14 (2015-08-09), comparing item under mouse with userdata (in strings format), as shown in the video is not necessary anymore. You can use nil, just like with any other functions.

Code Snippet:

function Msg(param)
  reaper.ShowConsoleMsg(tostring(param).."\n")
end

function Main()
  
  item_mouse, mouse_pos  = reaper.BR_ItemAtMouseCursor() -- Get item under mouse
  
  if item_mouse ~= nil then -- If no item under mouse
      
      -- INSERT CODE HERE
  
  end -- ENDIF no item under mouse
  
end

reaper.ShowConsoleMsg("")
Main()

Next videos will show other ways to get items, and go further with conditions !

Hope you still enjoy it !

Note : I investigate a way to provide exercise for premium members. Tell me if you are interested !

Help us translate the subtitles of this video in your language using Amara.org !