Saving Slider Positions

Hi Guys,
I am trying to rework this script:
on init declare %save[3] {number of mic signals} declare $sync_id declare ui_slider $Slider1 (0,100000) declare ui_slider $Slider2 (0,100000) declare ui_slider $Slider3 (0,100000) declare ui_menu $Menu declare $tmp declare const $GFX := -1 declare const $GROUP := 0 add_menu_item($Menu,"Save",0) add_menu_item($Menu,"Load",1) end on on async_complete if ($NI_ASYNC_ID = $sync_id) $sync_id := -1 end if end on on ui_control ($Menu) select ($Menu) case 0 save_array (%save,0) case 1 $sync_id := load_array (%save,0) while ($sync_id # -1) wait (1) end while $Slider1 := %save[0] $Slider2 := %save[1] $Slider3 := %save[2] end select end on on ui_control($Slider1) set_engine_par($ENGINE_PAR_FORMANT,$Slider1,$GROUP,0,$GFX) $tmp := get_engine_par($ENGINE_PAR_FORMANT,$GROUP,0,$GFX) %save[0] := $Slider1 end on on ui_control($Slider2) set_engine_par($ENGINE_PAR_FORMANT,$Slider2,$GROUP,0,$GFX) $tmp := get_engine_par($ENGINE_PAR_FORMANT,$GROUP,0,$GFX) %save[1] := $Slider2 end on on ui_control($Slider3) set_engine_par($ENGINE_PAR_FORMANT,$Slider2,$GROUP,0,$GFX) $tmp := get_engine_par($ENGINE_PAR_FORMANT,$GROUP,0,$GFX) %save[2] := $Slider3 end on
I don't want to access load and save through a menu but as two separate buttons, how would I go about this? I have looked in the KSP Manual and it only shows examples of using tables so I am not sure how to do it. Thanks in advance!
Answers
-
You would just do it with two buttons, so you split each case of that $Menu's select-case into separate UI callbacks for load and save. Pretty simple.
0 -
That's great, have just worked that out! Is there a way to print the name of the preset onto the gui? Also I was thinking could you load say 6 presets for different combinations of buttons and then have a button that cycles between those six loaded presets?
0 -
If you store the preset name in a separate string array NKA, then you can also show them on the GUI. At that point it's better to use
load/save_array_str()
.0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 786 Tech Talks
- 4.1K Native Access
- 16.6K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 380 Battery 4
- 847 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators