To start scripting
- start Kontakt and create a new instrument
- click on the wrench symbol
- click on “Script Editor” and then “edit”
- in the window below you write your code
The Script Tabs
You can use all the 5 tabs to create independent UI’s or to separate different scripts (for better clarity). But be careful the code inside different tabs is not really independent from each other. There are commands or callbacks which are affecting each other (like the on note callback).
Executing your Script & Error Reporting
When you hit the apply button your script gets executed immediately. However if there are any errors, Kontakt will not execute the script but report the first error with a status message below. It also marks the affected line of code. However it will not report all kind of errors. Eg. it doesn’t show runtime errors. Furthermore you will probably find the whole error reporting and debugging very nerve-racking. However the automatic warnings are still a good help to quickly find typos and slips.
The “Title for The Script” field
The Text you put into the “Title for the Script” field is also visible on the respective UI tab outside the edit mode (wrench button). But only when using multiple tabs in combination with the “make_perfview” command. The “make_perfview” command just makes the actual script tab visible outside the edit mode. You need it whenever you make a custom UI with knobs, buttons etc (of which more in later tutorials). Try it yourself by putting the following code into 2 or more tabs and enter some text into the “Title for the Script” field:
on init make_perfview end on
However for code writing you should rather use an “external” editor which makes coding much easier like coloring your code working with indents and offering great additional features like syntax checks, macros etc. When you are done writing simply copy your code from your external editor, paste it into Kontakt and click apply . Nil’s Liberg’s K Script Editor and Sublime Text are great tools. Of course you can also use any text editor which already simplifies a lot because of the much bigger working space … scrolling sucks ;)