# NKA preset file browser - How to make it work with purge_group switches?



## filionka (May 26, 2016)

Hi fellow Kontakt 5 tinkerers (many of you are pros too and maybe it's your help I need)

I started out with a script I had found somewhere on the internet which made it possible to save and load a knob value in NKA files. Through trial and error I managed to make it work with the file browser script from the KSP manual. Now I can load and save NKA files with effects and modulation engine parameters through the file browser and it works GREAT, but I can't get it to work with my purge_group switches. 

My script does exactly what Output's REV file browser does minus loading/unloading the right sample groups for the NKA preset. 
Watch this video from 5:47 to see what I mean:




The only difference is I don't have drop down menus to load/unload samples like REV has in layer 1 and 2. I have it connected to switches instead. I believe Output's SIGNAL also has it connected to switches though. However, I don't think it would matter. 

Does anyone know how to make my purge_group switches work with the NKA presets and the file browser?

I could post my script here but I would prefer to work with someone here in private. If the solution is complex I would gladly pay for it. 

All the best,

/Joakim


----------



## Andrew Aversa (May 26, 2016)

What exactly is the issue you're having with purge_group? Is it possible you are trying to purge in a function (not allowed)? Depending on your browser implementation, you will need to tie the actual purge command to a UI control. If the UI control you're using is a "Load" button then you need to implement a while/wait loop that checks if the NKA is fully loaded - in the UI callback - and then once it IS loaded, run the purge stuff there.


----------



## filionka (May 26, 2016)

zircon_st said:


> What exactly is the issue you're having with purge_group? Is it possible you are trying to purge in a function (not allowed)? Depending on your browser implementation, you will need to tie the actual purge command to a UI control. If the UI control you're using is a "Load" button then you need to implement a while/wait loop that checks if the NKA is fully loaded - in the UI callback - and then once it IS loaded, run the purge stuff there.



I have not tried it in a function no but the other suggestion you wrote sounds like it would definitely work. I'll try that.

The NKA files can currently save the state of the purge switches (on or off) but it doesn't recall what task they should perform. I have the switches in the callback section and they are tied to the purge command and it works like it's supposed to. The saving/loading in the nka file is the thing I have trouble with. It works like it should with the effects and modulations though.

Thanks for the reply. I will try the while/wait loop out!

All the best,

/Joakim


----------



## EvilDragon (May 26, 2016)

zircon_st said:


> If the UI control you're using is a "Load" button then you need to implement a while/wait loop that checks if the NKA is fully loaded - in the UI callback - and then once it IS loaded, run the purge stuff there.



Just an adjunct - this needs to be used along with async_complete callback. See KSP reference for an example.


----------

