Old 04-17-2018, 05:21 PM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default Lua GUI Presets

EUGEN27771's gen_Envelope-based Compressor v2.eel has presets load/save.

I just need something like that to save the current settings for a Lua GUI Strum Pattern creator I'm working on for JS Midi Strum.

MusoBob is offline   Reply With Quote
Old 04-17-2018, 06:28 PM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

The easiest way I've found is to have a function (or more likely, a bunch of functions) that:

1. Grabs the values from every important GUI element and tosses them in a table.

2. Saves that table to a text file in whatever format you want. I actually found a neat function that writes it as legal Lua code, which is handy for the next step.

3. Loads the text file and transfers the data back into a table.

4. Goes through each value in the table and applies it to the appropriate GUI element.

That's how Radial Menu does it, and I've found it to be really useful. See the functions save_menu and load_menu for a starting point.

I should also note that every GUI element's input methods have been modified so they store their values in mnu_arr automatically, and there are a number of functions (i.e. update_context_elms that just copy values from the table to the elements at various points.

From there, a preset system would just need to save them to different files, or somehow segregate them within one file - perhaps with named comments so the loader could search for names and then only read that portion of the file.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 04-18-2018, 12:05 PM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Thanks for that, just thought they may have been a ready made script, but I will look into that.
MusoBob is offline   Reply With Quote
Old 04-18-2018, 03:14 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Here is presets management code:

https://github.com/ReaTeam/ReaScript..._functions.lua
X-Raym is offline   Reply With Quote
Old 04-18-2018, 03:33 PM   #5
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Thanks ! awesome.
MusoBob 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 06:22 AM.


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