Last active
May 4, 2019 21:54
-
-
Save catfact/7a8f5ae56341c144e235fe83abdfdd69 to your computer and use it in GitHub Desktop.
module providing "factory preset" functionality for norns scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local factory = include('lib/factory') | |
| function init() | |
| --- add parameters here... | |
| -- this will copy .pset and .pmap from dust/code/example/data/*, to dust/data/example/*, | |
| -- (without overwriting existing files) | |
| factory.init() | |
| -- then this will load the default values (user or factory) | |
| params:default() | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local factory = {} | |
| factory.init = function() | |
| local name = norns.state.name | |
| -- local data files (factory presets) | |
| local factory_data = norns.state.path .. 'data/' | |
| local factory_pset = factory_data .. norns.state.name .. '.pset' | |
| local factory_pmap = factory_data .. norns.state.name .. '.pmap' | |
| -- top-level data files (user presets) | |
| local user_data = norns.state.data | |
| local user_pset = user_data .. name .. '.pset' | |
| local user_pmap = user_data .. name .. '.pmap' | |
| local f = io.open(user_pset) | |
| if f == nil then | |
| os.execute("cp "..factory_pset.." "..user_pset) | |
| end | |
| f = io.open(user_pmap) | |
| if f == nil then | |
| os.execute("cp "..factory_pmap.." "..user_pmap) | |
| end | |
| end | |
| return factory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment