I'm stuck on this :- I have an %array to save and load the gain parameter of a gainer in slot 1 of instrument insert fx. The full script below loads and saves the $gain ui_knob value but does not load / set the gain parameter value in the engine.
set_engine_par($ENGINE_PAR_GN_GAIN,$gain,-1,0,1)
I have tried several options including expanding the array and including the line above but it makes no difference so I can't figure it out :( . What am I missing? Any help would be greatly appreciated in a clear explaintion of how to do this to a beginner. I cannot find a clear explanation in the KSP reference manual for saving of a ui_knob/slider including it's path to it's engine parameter then how to recall it. If you know of one then please post the link Thank you :-
on init
declare $i
declare $load_arr_id := -1
declare $save_arr_id := -1
declare ui_button $Load
declare ui_button $Save
declare ui_knob $gain (0, 1000000,1)
make_persistent($gain)
declare %preset[1]
end on
on ui_control ($gain)
$i:= 0
while ($i < 1)
%preset[$i] := $gain
set_engine_par($ENGINE_PAR_GN_GAIN,$gain,-1,0,1)
inc($i)
end while
end on
on ui_control ($Load)
$load_arr_id := load_array(%preset, 0)
end on
on ui_control ($Save)
$save_arr_id := save_array(%preset, 0)
end on
on async_complete
if ($NI_ASYNC_ID = $load_arr_id)
$load_arr_id := -1
$Load := 0
if ($NI_ASYNC_EXIT_STATUS = 1)
$i := 0
while($i < 1)
$gain := %preset[$i]
inc($i)
end while
end if
end if
if ($NI_ASYNC_ID = $save_arr_id)
$save_arr_id := -1
$Save := 0
end if
end on