Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: BBA on August 01, 2016, 05:10:55 PM

Title: Change of config with a Lua script
Post by: BBA on August 01, 2016, 05:10:55 PM
I would like to have your suggestions about writing a Lua script to change the ML config files at will  (and restart ML with the chosen configuration).

Let's suppose we have saved in 2 different directories on the CD card, all the ML/SETTINGS files for 2 different situations:
for instance, a standard situation for 1920x1080x24fps and a special one for  3260x1320x12fps .

We created those directories under the ML directory (to keep them when formatting), let's say:
dir1 = ML/MY_DATA/1920     and
dir2 = ML/MY_DATA/3260 .

To start using a new config, let's say, the 3260x1320x12fps one, we only have to replace the files present in the ML/SETTINGS directory with all the ones that we saved in ML/MY_DATA/3260.

It seems obvious when using a computer to read/write files between directories.
But, I would like to do that in the field, without computer.


One answer would be to be able to send, from within a Lua script, commands to the OS  like ( in DOS syntax ) :
run "del ML\SETTINGS\*.*"
run "copy ML\MY_DATA\3260\*.* ML\SETTINGS\" 
Another answer:
The ML Lua API contains the dryos module with directory:files() and remove( filename) to delete all the files from ML/SETTINGS.
But then, how should we copy the files ?


Many thanks in advance !
Title: Re: Change of config with a Lua script
Post by: Walter Schulz on August 01, 2016, 06:05:32 PM
And why?
You have to use computer once, creating two directories in ML\Settings according to http://www.magiclantern.fm/forum/index.php?topic=8499.0
Title: Re: Change of config with a Lua script
Post by: BBA on August 01, 2016, 07:08:39 PM
Existing and very beautifully done ( I didn't know).
Sorry.

(Topic may be deleted)