View Single Post
Old 05-16-2018, 02:27 PM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default Lua: Setting Item color

Hello scripters,

I've been trying to get and set item colors. But nothing I'm doing is working. I'm not getting script errors... just no change of color.

I've been using these commands:

To get item color value (this seems to be working fine):
Code:
 Color_Val = reaper.GetMediaItemInfo_Value(Item, "I_CUSTOMCOLOR" )
And to impose a color value (this seems to not be working for me):
Code:
 reaper.SetMediaItemTakeInfo_Value( Take, "I_CUSTOMCOLOR",88888888.0 )
No matter what I do, I can't re-color an item. Any help on what I'm missing?

Here is my test script:
Code:
function Msg (param)
  reaper.ShowConsoleMsg(tostring (param).."\n")
end

function Main()

  reaper.ClearConsole()
  Num_of_Items = reaper.CountSelectedMediaItems(0)
  Msg("Number of items: ".. Num_of_Items)
  ii = 0
  Note_Num = 0
  
  for i = 0, Num_of_Items - 1 do



    Item = reaper.GetSelectedMediaItem(0,i)   
    Take = reaper.GetMediaItemTake(Item, 0)
    
    Item_Track = reaper.GetMediaItemTrack(Item)
    _, Track_Name = reaper.GetTrackName(Item_Track, "")
    
    _, Take_Name = reaper.GetSetMediaItemTakeInfo_String(Take, "P_NAME", Track_Name.. "Soft_".. Note_Num.. "_rr_".. i % 8 + 1 ,1)
    
  
    
    if i >=  Num_of_Items - 20 then
    Color_Val = reaper.GetMediaItemInfo_Value(Item, "I_CUSTOMCOLOR" )
        ii = ii + 1
        Msg(ii.. ": ".. "Item: ".. i..", "..  Take_Name.. "  color: ".. Color_Val)

    end

  
    
    reaper.SetMediaItemTakeInfo_Value( Take, "I_CUSTOMCOLOR",12345678 )

    

            
  end
      
end
    
Main()
Cheers,

Andrew K

Last edited by Thonex; 05-16-2018 at 02:43 PM.
Thonex is offline   Reply With Quote