Kray3 SDK/Script basics

From Kray
Revision as of 15:18, 15 August 2012 by Jure (Talk | contribs) (Double)

Jump to: navigation, search

Script Basics

Welcome to Kray3 Script! Kray script is scripting language that allows you to control Kray render engine. It is very easy to use it so anyone can try it, although any previous programming background experience will come handy.

In this first section we will explore basic data types and operations that you can use in Kray Script.

Data Types

You can use all the standard data types in Kray. Here is just a quick description of each of them:


Strings can be used by wrapping them in singe ' or double " quote marks. For example:

"this is string";
'this is also string'


Double is a type of number that contains twice as many binary digits. You will mostly use this type of number.


var pi, 3.14159;
echo pi;



Vectors are used to define position in space. Whenever you need to use vectors in Kray script you need to declare them with vector command in round brackets: (x,y,z)


vector myvector, <1,2,3>;



Orientation matrix or axes defines orientation in space with heading, pitch and bank values. You declare orientation with 'axes' command and values (degrees) in angled brackets:


axes south, <180,0,0>;


Orientation is rotation matrix of x,y and z vector. You can lookup each of the vectors like this:


echo <0,0,0>.x // returns X vector in the matrix: (1,0,0)
echo <0,0,0>.y // returns Y vector in the matrix: (0,1,0)
echo <0,0,0>.z // returns Z vector in the matrix: (0,0,1)


Arithmetic operations

Several standard operations can be used on data types. Please see the following section for details:

Arithmetic operations


Declaring variables in Kray Script is much like in any other language. The following commands are available for each of the data types:


// String variable:
string sometext, "we just declared a string";
// Double variable:
double somenumber, 3.14159;
// Vector variable:
vector somevector, (1,0,1);
// Orientation variable:
axes northwest, (-45,0,0);



 function MyFunction(string text,var num){ 
     echo Function args are +text+ and +num; 

Loops and Conditional statements

There are two statements available in Kray script: IF and WHILE:


Executes code as long as condition is true

while {....}


Executes code if condition is true.

if {... }

Common commands