Old 04-07-2019, 06:24 AM   #1
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 132
Default How to Transfer Item id from scripts?

Hi!

Working on a string of scripts, and something that I really think would help to streamline one that I'm currently in the middle of would be the ability to either transfer an item's userdata from one script to the other, or somehow "select" an item by its track item number (for reference: reaper.GetMediaItemInfo_Value( item, "IP_ITEMNUMBER" ))

I figured a way to do this with tracks utilizing the "select track number ()" actions, but unfortunately haven't found a direct way to do this for items within a track.

The only way to do this currently, I believe, is to run a for/while that searches a track's item inventory one by one for the stored item number's id, which is the process I would like to streamline.

EDIT:

I have found the SWS actions, Restore and Save selected track(s) selected item(s), but unfortunately there are only 5 slots.

Update:

Turns out, that not even my method to store track id's *fully* works, because the "select track (number)" scripts deselect all other tracks in the process. LAME.

Last edited by Dafarkias; 04-07-2019 at 08:59 AM.
Dafarkias is offline   Reply With Quote
Old 04-07-2019, 04:56 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,971
Default

Quote:
somehow "select" an item by its track item number

Better use API functions as much as possible. This keeps things simple and more predictible withut dependency and other actions behaviors.



Good news is that what you are looking for already exists:


reaper.GetTrackMediaItem( tr, itemidx )


Note that this doesn't "select the item", it just returns an item for the script, but you have function to seletc items after that if you want.


reaper.SetMediaItemSelected( item, selected )
X-Raym is offline   Reply With Quote
Old 04-08-2019, 12:30 AM   #3
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 132
Default Thanks

Thanks! I really don't like when I overlook stuff right in front of me.

Is there​ also an equivalent API function that gets a track by id?

Love your website btw
Dafarkias is offline   Reply With Quote
Old 04-08-2019, 02:19 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,971
Default

Track by ID ? This is basic. It's the GetTrack function... :P note that it is 0 based ID so track 1 is id = 0, track 2 is id = 1 etc... :P


We have various tutorial series out there about basic of Lua and reading the doc, incmuding my video tutorial series about reascript (link in signature), maybe take a look, basic functions are explored.
X-Raym is offline   Reply With Quote
Old 04-08-2019, 02:53 AM   #5
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 132
Default Re

Thanks, sorry to be a bother.
Dafarkias is offline   Reply With Quote
Old 04-08-2019, 02:56 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,971
Default

Don't worry, it is not easy to get started and we all started by asking basic questions, but once you are put on traks, it become more easy :P


Good luck with scripting !
X-Raym is offline   Reply With Quote
Old 04-08-2019, 05:25 AM   #7
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 132
Default Re

Just want to say thanks again:

Kinda worked myself into a stupor yesterday scripting, but after a night's rest and the functions you brought to my attention, it really wasn't that difficult to compile the "track id" portions of my scripts.

Thanks!
Dafarkias is offline   Reply With Quote
Old 04-08-2019, 06:13 AM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,971
Default

Glad you made it !



Welcome aboard ReaScripting :P
X-Raym is offline   Reply With Quote
Old 04-08-2019, 10:05 AM   #9
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 132
Default ReRe

Here is the aforementioned script, as an easter egg.

Test at your own risk.
Dafarkias is offline   Reply With Quote
Reply

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 11:04 PM.


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