Up to date files and documentation on X-Raym REAPER ReaScripts Repository
https://github.com/X-Raym/REAPER-ReaScripts/tree/master/Templates/Script%20Preset
Preset script files allow you to modify main variables and functions from a script file without modifying its source, so that your modifications will be preserved even if the parent script is updated by its developer. It only works with scripts written with this concept in mind.
- Create a new Preset script file next to the Parent script file of your choice. You can name it whatever you want. You can do it via REAPER Actions window → New Action button → New ReaScript menu.
- Copy the Preset script.lua content. For that, you can click here, and do CTRL/CMD+A to select all text, and then do CTRL/CMD+C to copy the code.
- Paste the code into the Preset script file via the opened IDE (code editor) window.
- Copy parent script file name and paste it to the User Config Area 1/2 section of the preset script.
- Open the Parent script file into a code editor. It can be REAPER IDE, via Actions window → Edit Action button → ReaScript IDE menu.
- Copy parent script User Config Area variables and paste to the User Config Area 2/2 section of the preset script over the template variables.
- Alter the User Config Area 2/2 variables in the preset script as you want.
- Save your Preset script file (CTRL/CMD+S if done via REAPER IDE).
The preset script is now ready to use.
- Wrap main code in a
Init()
function as in Parent script.lua. - Add boolean to prevent running
Init()
directly if the script is called by preset script. - Have a User Config Area at top of the script.
- Prevent saving last input if necessary (for script with GUI) so that this feature stay for main script (not the preset, which usually will not have any popup).