# Custom Knob Problem (My first steps with KSP)



## gnd.tekin (Jul 29, 2014)

hey folks

I'm just signed up here, really a awesome forum. I would really appreciate it if you guys could help me with this problem. 

I'm making my first steps with scripting in Kontakt 5 and i decided, for my first project, to build a custom knob. I got the knob from knobman (101 frames) and i got the instructions on how to intigrate it in kontakt from this website Custom knob tutorial

I'm following exactly every step.

1) Loading my Instrument in Kontakt and creating a resource container 
2) saving it to the location where the instrument is saved
3) placing my png knob and txt file in the pictures folder
4) placing my script.txt file in the script folder and finally loading the script txt to kontakts script section. 

But it doesn't work like it supposed to be?

Why it looks like this at the end ? 







The knob has no function, the script is just placing the png on the top of the instrument.

My script



> on init
> 
> make_perfview
> set_ui_height_px(350)
> ...




The text for the knob ( is saved with the knob.png in the pictures folder



> Has Alpha Channel: yes
> Number of Animations: 101
> Horizontal Animation: no
> Vertical Resizable: no
> ...



Many thanks in advance i hope someone can help me. I'm very curious about why it doesn't work.


----------



## gregjazz (Jul 29, 2014)

What text editor did you edit/make the txt file in? Sometimes if it doesn't have the correct carriage returns / newlines it won't work.


----------



## Big Bob (Jul 29, 2014)

Welcome to the forum.

I'm not quite sure what you are saying doesn't work.

1. Your posted code doesn't match the picture. Perhaps you simplified it by reducing it to one knob but then you probably should have also changed the screen shot to match.

2. As your code is posted, there is a hard CR after the first line of ORed masks but that is probably another forum posting accident or you wouldn't be able to compile the script in K5.

3. As it stands, with the CR removed, your code compiles and runs OK here but of course I don't have your graphics file. However, I tried it with pv_bank_knob_big.png and, as I said, it works OK.

4. When you post code, please use code tags not quote tags. That will hopefully avoid things like extraneous CRs, etc.

Of course, your drag value of -101 is rather low so the rotation is probably a lot slower than would be comfortable. Also positioning the knob at 0,0 may or may not be what you intended since your comment reads 'place it on the performance view'. More correctly, it might be said to place it on the panel (performance view or otherwise)

I should also mention that there is no need to include the hide_part stuff since you are reskinning the slider (not to mention that sliders don't have any of those things anyway :lol: )

I don't know if any of the above will be helpful to you but until you state a more specific problem, it's about all I can come up with :roll: 

Rejoice,

Bob


----------



## gnd.tekin (Jul 31, 2014)

@gregjazz

I'm just using the standart Editor in Windows. I have read somewhere, that you have to save your txt files in UTF-8. The problem is, if i save the txt file in UTF-8 and load it to Kontakts script editor some strange characters appers befor the on init line ?

sorry for my bad english o[])


----------



## gnd.tekin (Jul 31, 2014)

@Big Bob

Thanks for your fast reply :D 

This is my first steps with KSP and i counted on the tutorial on how to buld a custom knob, i don't knob why this dosn't work? I have a 101 frame knob png and the script from the website. The guy in the tutorial (posted link in my first post) have a working knob, after he's finished. But my kontakt just places the knob.png in the performance view i cant control it like to switch it from minimum to maximum.

Can you tell me what a CR and ORed is? As i understand you say, if i remove the CR, the code should be working fine.

Thanks Anyway o-[][]-o I will get the book KSP Scripting 1 from Mike Novy. I don't know if there is any usefull tipps in the book on how to build GUI in kontakt? Do you have any experience with the book?


----------



## Robym (Jul 31, 2014)

sometimes it does that when you do your own knobs in photoshop and the size is not correct

are you sure the full png size is a multiple of 101 in (pixel) height?


like when you do a button png of 120pixel (6 frames pic) then you resize it in photoshop and the new height is not anymore a perfect multiple of 6

just an idea

R.


----------



## Big Bob (Jul 31, 2014)

> But my kontakt just places the knob.png in the performance view i cant control it like to switch it from minimum to maximum.



To remove any doubt about your custom graphics possibly being at fault, try using the standard K5 graphic that I tried yesterday. Change your 'image assignment' code line to this:


```
{ assign the image file } 
set_control_par_str(get_ui_id($custom_pitch), $CONTROL_PAR_PICTURE, "pv_band_knob_big")
```

To try this, make sure the instrument is *NOT* pointing to an .nkr file (otherwise K5 won't find the image).
Also, change your mouse drag value from -101 to -1000 so your knob will rotate little faster. 



> Can you tell me what a CR and ORed is? As i understand you say, if i remove the CR, the code should be working fine.



CR is the ASCII code for carriage return. By 'ORed' I am referring to the string of hide masks you are combining with the* .or.* operator. Those code lines as you posted them have an extraneous CR embedded in them but if your code was compiling in K5 OK, the CR probably isn't in your original code. But to rule this out, you can just remove the hide code lines also (they really aren't needed anyway).


Rejoice,

Bob


----------



## Mike Greene (Jul 31, 2014)

One thing that would probably make things easier is to use Nils Liberg's script editor here:
http://www.nilsliberg.se/ksp/

Better yet, if you have Sublime Text, then check out this thread:
http://www.vi-control.net/forum/viewtop ... ht=sublime


----------



## mk282 (Jul 31, 2014)

No, you should not save the .txt file in UTF-8 encoding. You should use ANSI for that one.


----------



## gnd.tekin (Aug 3, 2014)

Hey guys it worked =o 

I've renamed the knob to pv_bank_knob_big.png and saved everything with Nils Liberg's script editor. 

Now i can control the knob.

Many thanks for the tips guys you are the best o=?


----------



## Big Bob (Aug 4, 2014)

I'm not sure I understand why you had to rename your custom png to make it work but maybe I'm not following what you are saying.

In any case, I guess if you are happy with it that's all that matters. :D 

Rejoice,

Bob


----------



## L i n u s (Jun 28, 2016)

I have the exact same problem. When i create a knob it just shows the image with no functionality. 

The knob is made from the knob man web service, it has 60 steps and is 100x6000px. Tried to re-save the image but that only resulted in the alpha channel being lost.






.txt data file is made with TextWrangler. There is no ANSI encoding in Mac?


----------



## polypx (Jun 28, 2016)

Two things might be relevant - 1. is that you're displaying a different text file than the knob you're assigning, so you may want to check which knob is the one you want, 2. you need a carriage return after the last line of the text file


----------



## L i n u s (Jun 28, 2016)

Thanks for your reply! There is just one knob that is assigned in the code in the screenshot. What you see in the UI is the first four "frames" of the 60 different knobs in the png image.

Will try the carriage return. You mean just a blank return att the end of the script?


----------



## L i n u s (Jun 29, 2016)

Problem solved. What i did was to create a new .txt doc for the image data and write everything manually. For some reason it did not work to copy-paste the code from the tutorial.


----------



## Yahiaamine (Jan 13, 2017)

L i n u s said:


> Problem solved. What i did was to create a new .txt doc for the image data and write everything manually. For some reason it did not work to copy-paste the code from the tutorial.


what have you done dude i got the same exact problem


----------



## Lindon (Jan 13, 2017)

do what he says in his post and write the .txt and see if that fixes it.


----------



## EvilDragon (Jan 13, 2017)

.txt files need to end with an empty last line, and should have LF endings, not CR. Perhaps CR/LF works, but having LF endings is safe.


----------



## Yahiaamine (Jan 13, 2017)

OMG thank you so much Guys It works (You ROCK)
@Lindon @EvilDragon I LOVE U


----------



## Lindon (Jan 16, 2017)

slightly wierded out...


----------

