Kray3 SDK/Script basics

From Kray
Revision as of 11:04, 15 August 2012 by Jure (Talk | contribs) (Data Types)

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

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

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

Double

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

<syntaxhighlight lang="kray3">

var pi, 3.14159;
echo pi;

</syntaxhighlight>

Vector

Matrix

Arithmetic operations

Variables

Functions

 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:

while

Executes code as long as condition is true

while {....}

if

Executes code if condition is true.

if {... }

Common commands

echo

help