# Can't get custom control to display



## GregMalick (Sep 3, 2018)

Please help... I can't see the error:

in C:\Users\Alice\Documents\Native Instruments\Kontakt 5\pictures\buttonx.png
and C:\Users\Alice\Documents\Native Instruments\Kontakt 5\pictures\buttonx.txt






both are attached.

scrap of init code.

on init
set_script_title("My First Script")
make_perfview
set_ui_height_px(250)
set_ui_width_px(500)
declare ui_button $captureRhythm
set_control_par_str(get_ui_id($captureRhythm),$CONTROL_PAR_PICTURE,"buttonx")

I have stared at this for what feels like hours.
All I get is a button with the text "captureRhythm".
*Please, someone help.*


----------



## Ecliptiq Audio (Sep 3, 2018)

Hi,

In the text file, delete the Type: switch line. That's why it's not working. You don't need that.

Regards,
Peter


----------



## GregMalick (Sep 3, 2018)

Still doesn't work.
Do I need to remove and then add a Kontakt instrument back before a custom control will display?

on init
set_script_title("My First Script")
make_perfview
set_ui_height_px(250)
set_ui_width_px(500)
declare ui_button $captureRhythm
set_control_par_str(get_ui_id($captureRhythm),$CONTROL_PAR_PICTURE,"buttonx")


----------



## Ecliptiq Audio (Sep 3, 2018)

Now there's a an extra empty line at the end of the text file. There should be only one.


----------



## GregMalick (Sep 4, 2018)

I remove the extra line. Still can't see the control.

I've stripped the script to:

on init
set_script_title("My First Script")
make_perfview
set_ui_height_px(250)
set_ui_width_px(500)
declare ui_button $captureRhythm
set_control_par_str(get_ui_id($captureRhythm),$CONTROL_PAR_PICTURE,"buttonx")
end on


----------



## Jdiggity1 (Sep 4, 2018)

Create a resource container via instrument options, which will create a pictures folder. put your png and txt in there.


----------



## GregMalick (Sep 4, 2018)

I didn't think that was necessary for a test:


But I'll try to figure out how to do that.


----------



## GregMalick (Sep 4, 2018)

OK there seems to be something fundamental I don't understand.
I've been trying to write and test a script against an existing Kontakt instrument (Scarbee A-200).
The code actually works fairly well (but it's not complete).
But I can't get a custom control to display.

When I open a standalone Kontakt (not Kontakt as a plugin in Cubase) and add the script code, the control displays fine.

*Are there restrictions on creating scripts that can be run in an empty slots of third part Instruments and display controls for those scripts?*


----------



## EvilDragon (Sep 4, 2018)

GregMalick said:


> Are there restrictions on creating scripts that can be run in an empty slots of third part Instruments and display controls for those scripts?



I don't think there are.


----------



## tonewill (Sep 4, 2018)

Just to let you know that it works here using your posted 'init' and unaltered txt file. I put the txt and png in the same path under my name.


----------



## GregMalick (Sep 5, 2018)

So you put the files in C:\Users\*your-name*\Documents\Native Instruments\Kontakt 5\pictures\
and it worked ? ! ? !

I don't understand ! ! ! 

Did you create a resource Object (which I'm still trying to figure out) or what...


----------



## EvilDragon (Sep 6, 2018)

If you put the graphic in the path above, you don't need a resource container created. However, if you do create a resource container, the graphics should go within the Resources/pictures folder. But, since you're adding stuff to a library that already has a resource container (if I'm understanding correctly), that won't work.


----------



## tonewill (Sep 6, 2018)

GregMalick said:


> So you put the files in C:\Users\*your-name*\Documents\Native Instruments\Kontakt 5\pictures\
> and it worked ? ! ? !
> 
> I don't understand ! ! !
> ...


I just started with a new instrument, added your init code and put the png and txt in the path above. The only difference is that the path shows as "my documents" on mine (windows 7) but I think the underlying path is documents anyway.


----------



## GregMalick (Sep 6, 2018)

EvilDragon said:


> If you put the graphic in the path above, you don't need a resource container created. However, if you do create a resource container, the graphics should go within the Resources/pictures folder. But, since you're adding stuff to a library that already has a resource container (if I'm understanding correctly *[*_*-- yes you are]*_), that won't work.


*EvilDragon, that's it! *I was sure there was something fundamental I wasn't understanding.

So is it possible to write a midi "wrangling" script for use in other instrument effect slots that can display Custom controls? That is when the instrument is already using a resource container.

Sounds like _*not*_. Sounds like no work-around.


----------



## EvilDragon (Sep 6, 2018)

When an instrument is already using a resource container, you should still be able to use the graphics from the user documents folder path as mentioned before...


----------



## GregMalick (Sep 7, 2018)

tonewill said:


> Just to let you know that it works here using your posted 'init' and unaltered txt file. I put the txt and png in the same path under my name.



OK, using standalone Kontakt, I created a New Instrument and put in the "init-w/button" in an empty slot and the png displays fine. Also display fine in the Kontakt VST plugin in Cubase 9.5

But the png doesn't display when you put the "init-w/button" in an empty slot in an existing Instrument like Scarbee-A200. Tried other instruments -- same thing.

*Anybody have any thoughts on what I'm may be doing wrong when I put the script in an empty slot of an existing Instrument?*


----------



## geronimo (Sep 7, 2018)

Need your .png file to be in the Resources / Pictures folder of the corresponding library.
Reading page 235 of the current KSP Reference manual can be instructive.


----------



## GregMalick (Sep 7, 2018)

geronimo said:


> Need your .png file to be in the Resources / Pictures folder of the corresponding library.
> Reading page 235 of the current KSP Reference manual can be instructive.





EvilDragon said:


> When an instrument is already using a resource container, you should still be able to use the graphics from the user documents folder path as mentioned before...



Seems like I'm getting contradictory ideas here.


----------



## EvilDragon (Sep 7, 2018)

Hmmm. Actually it seems that this in fact really doesn't work with encoded libraries. At least not from the user documents path!

So, here's what you need to do to make it work:

1. Browse to the folder where the library is installed (A200 in your case, say)
2. Look for where the NKR file is, usually it's in the Samples folder
3. Create a folder called "Resources" here, then create a subfolder in it called "pictures"
4. Place your graphic and txt files there
5. Try your script now!


What happens here is: once a library has an assigned NKR file to it already, it *only ever* expects graphics and other assets to come from that NKR fiile itself. So to add stuff to it, you need to create the "unpacked" NKR by manually creating those Resources and pictures folders, so that you can add stuff to it. Just make sure *never* to overwrite the original NKR, as this will delete all the graphics and other assets it has in it.


----------



## geronimo (Sep 7, 2018)

GregMalick said:


> Seems like I'm getting contradictory ideas here.


My explanation is incomplete by not mastering English language, sorry.
Thanks to EvilDragon for completing.


----------



## GregMalick (Sep 8, 2018)

First off, I really want to thank everyone for their kind assistance.

EvilDragon, your suggestion works perfectly.
It's not an ideal solution since the scripts Resources need to be manually copied into any instrument the script is used in (sigh).
It would be wonderful if in some future KSP release, the script could point to a directory where it could always find the resources.

But que sera, sera. At least this puts me in a position to pretty up the UI with some Custom Controls.


----------



## GregMalick (Sep 10, 2018)

Quick Question:

*Can a Script have a different wallpaper than the background of an Instrument in an encoded Library?*
I can set_skin_offset(50000) in the script but the background turns black.

If I try to use $CONTROL_PAR_PICTURE to set another wallpaper, the Instrument's background changes.

*Is it possible to have the script's controls have a unique background than the instrument?*


----------



## EvilDragon (Sep 10, 2018)

Not fully, no. You can use a ui_label and place it at (0, 0), but instrument header will remain the same.


----------



## GregMalick (Sep 10, 2018)

EvilDragon said:


> Not fully, no. You can use a ui_label and place it at (0, 0), but instrument header will remain the same.


Awesome! That works for me. Thank you.


----------

