PDA

View Full Version : Script Editor/Compiler version 1.1


kotori
08-29-2006, 05:43 PM
Hi everyone,
The new 1.1 version of my free script editor/compiler (http://nilsliberg.se/ksp/) is now available for both Mac and PC. Thanks to Frank van Gompel for kindly helping out with porting it to OSX. While it is of course possible to use this program like a normal text editor for Kontakt scripts, those who use its compiler part may be interested in these syntax extensions:

family - organize your variables into logical groups:on init
``family settings
````declare x
````declare y
``end family
``
``settings.x := 10
``settings.y := 40
end on
import - split up large scripts into multiple files and factor out reusable functions to make scripts more comprehensible. Functions named "on_init" are treated a little differently - variables declared inside them are implicitly global so that they can be used by other functions in the same module (normally variables declared in functions are implicitly local). This sample shows how the first function module is imported into the main script: { Contents of file "crossfade.txt": }
function on_init``
``declare old_id
end function

function crossfade_to_note(new_id)``
``fade_out(old_id, 100000, 1)
``fade_in (new_id, 100000)
``old_id := new_id
end function

{ Contents of file "myscript.txt": }
import "crossfade.txt"

on note
``crossfade_to_note(EVENT_ID)
end on
namespaces - it's also possible (and advicable) to import functions into a namespace of your choice. In this case the main script might look something like:{ Contents of file "myscript.txt": }
import "crossfade.txt" as cf

on note
``cf.crossfade_to_note(EVENT_ID)
end on
Regards,
Nils L

Brian2112
08-29-2006, 07:37 PM
Well Done Nils!

Your editor makes it so much easier to program scripts (plus it saves a lot of time and code):D

Also, those who are familiar with other programming languages have an easier time adjusting to the KSP syntax.

Thanks so much! Great work!

...2112:)