Old 01-21-2018, 03:34 PM   #1
J Reverb
Human being with feelings
Join Date: Jul 2009
Posts: 656
Default Newbieland for JSFX and ReaScript Discussion

Covering LUA, EEL, JS with well commented examples it could be a great place to start for anyone interested in learning ..

Can we get a sticky ?
J Reverb is offline   Reply With Quote
Old 01-21-2018, 03:48 PM   #2
J Reverb
Human being with feelings
Join Date: Jul 2009
Posts: 656

For example
Item properties Toggle mute .Lua

--Toggle selected item mute state Lua
--J Reverb
--Commented Code Example

my_number_of_selected_items = reaper.CountSelectedMediaItems(0) 
--counts the number of currently selected items

if my_number_of_selected_items > 0 then 
--if the number of selected items is greater than 0 then do something

    for all_selected_items_counted = 0, my_number_of_selected_items -1 do  
      -- the total number of selected items -1 as they are counted from 0 upwards or zero based
      -- so 1234 becomes 0123 if you change the -1 to -2 you will see how this works      
      item = reaper.GetSelectedMediaItem(0, all_selected_items_counted)  
      -- Gets the counted selected items and holds them in 'all_selected_items_counted'
      --('0' being the active project, 'all_selected_items_counted' being the number of selected items)
      mute = reaper.GetMediaItemInfo_Value(item, 'B_MUTE') 
      -- Gets the current parameter value of the selected items 'B_MUTE'
      --('item' being 'all_selected_items_counted' 
      --'B_MUTE' being the parameter name from the function reaper.GetMediaItemInfo_Value
      -- https://www.extremraym.com/cloud/reascript-doc/#GetMediaItemInfo_Value 
      reaper.SetMediaItemInfo_Value(item, 'B_MUTE', mute-1)
      -- Sets the new value to the selected items based on the current value
      -- read from 'mute' = reaper.GetMediaItemInfo_Value(item, 'B_MUTE')
      -- We have to give it a value ! in this case it is 'mute-1' this is the value 
      -- of 'B_MUTE' -1 so each time it checks 'mute' and sets its new value 
      -- in this case its used to toggle the mute state of the selected items 
      -- https://www.extremraym.com/cloud/reascript-doc/#SetMediaItemInfo_Value
      -- This is needed to update the changes in the selected items 'item'   
    end -- ends if statement
end -- ends for count
J Reverb is offline   Reply With Quote
Old 01-22-2018, 03:38 AM   #3
Human being with feelings
X-Raym's Avatar
Join Date: Apr 2013
Location: France
Posts: 5,929

Note that there is a library of code snippet (well commented in general) maintained by the ReaTeam :P


I think that what need new scripters are tutorials about "what and how to use reascript" in a first place. I got a link in my description for my own video tutorial and articles in my signature, but there is other tuts avaible here and there on the web, including nice Lokasenna GFX one :P

Tutorial: Building a GUI in Lua.: https://forum.cockos.com/showthread.php?t=176662
X-Raym 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 10:31 AM.

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