View Single Post
Old 12-15-2017, 04:24 PM   #439
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,992
Default

Spaces are fine. Each line in Browse packages is a package. Packages may contain multiple scripts and files. Repositories contain multiple packages. Everything with a @version number and metadata is a package.

I meant that to reuse a file in multiple packages it must be saved under a different filename for each:

Code:
-- @description Package 1
-- @version 1.0
-- @provides ../Functions/MIDI functions.lua > Package 1/MIDI functions.lua

local path = ({reaper.get_action_context()})[2]:match('^.+[\\//]')
dofile(path .. "Package 1/MIDI functions.lua")
Code:
-- @description Package 2
-- @version 1.0
-- @provides ../Functions/MIDI functions.lua > Package 2/MIDI functions.lua

local path = ({reaper.get_action_context()})[2]:match('^.+[\\//]')
dofile(path .. "Package 2/MIDI functions.lua")
But in the case of your transposition scripts there are two better ways. First they could be released as a single package sharing the same version, changelog and other metadata.

Additionally it can be made as a single source file on the repository and have ReaPack install that 10 times under different names. (Assuming the scripts are all identical except for the interval variable.) Like this:

sr_Transpose notes.lua
Code:
-- @description Transpose notes
-- @version 1.0
-- @author Stephan Römer
-- @about
--   # Description
--
--   - this script transposes either all notes or selected notes by 1, 3, 5, 7 and 12 semitones up or down
--   - this script works in arrangement, MIDI Editor and Inline Editor
-- @link https://forums.cockos.com/showthread.php?p=1923923
-- @changelog + Initial release
-- @provides
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes +1.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes +3.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes +5.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes +7.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes +12.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes -1.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes -3.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes -5.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes -7.lua
--   [main=main,midi_editor,midi_inlineeditor] . > sr_Transpose notes -12.lua

local script_name = ({reaper.get_action_context()})[2]:match('([^/\\_]+).lua$')
interval = tonumber(script_name:match('-?%d+'))

for i = 0, reaper.CountSelectedMediaItems(0)-1 do -- loop through all selected items
  -- rest of the code, no need to copy/paste across 10 files anymore :D
end

Last edited by cfillion; 12-15-2017 at 05:01 PM.
cfillion is online now   Reply With Quote