Syntax rules

General

Alambik Script 4.0 is a language built up over many years with a great concern for making it as intuitive and easy to understand as possible. It is a "natural language," quickly grasped even by people without extensive technical backgrounds.

Thus Alambik lets users of different experience levels harness its powers in many different ways. Certain rules of syntax, however, must be used in all cases and are important to keep in mind.

In this section we will present Alambik's syntax for a variety of uses:

1. The syntax in general (what you need to know in order to create)
2. The syntax of actions on objects (to download or display AVOs)
3. The syntax of interacting with objects (to change audio volume, apply filters to images, resize icons, etc.)


The syntax in general

Unlike some languages, all Alambik instructions include two parentheses "()". These are an integral part of each instruction and must be retained, even when no parameters are being passed.

Example:

keyboard.wait()

Any text marked off with a /* and */ is a comment. Comments are automatically ignored by the Alambik interpreter. In general, comments can be placed in any area of a script consisting of spaces, tabs, or carriage returns.

Syntax :

// Comments …

/* Comments … */

; Comments

There are two kinds of comments permissible in Alambik : line comments starting with "//" or ";" and which end in a carriage return; as well as comment blocks which begin with "/*" and end in "*/".

Example :

keyboard.wait() // Wait for a keystrike...

keyboard.wait() ; Wait for a keystrike...

/*
Wait for
a keystrike...
*/
keyboard.wait()

You can use comments to disable one or several lines of instructions without having to actually erase them.

Example :

;screen.clear()
;…
;keyboard.wait()

or

/*
screen.clear()

keyboard.wait()
*/

Note: : it's often desirable to add comments in your script to ease maintenance and improvements.

First off, let's go over what makes up the beginning and the end of a script.

Each script must start with the instruction

screen.resolution.set(x,y)

This instruction opens the Alambik work screen. Without this instruction, it would be impossible to "see" your script in action.

Quite logically, your script must end with the instruction

script.stop()

which lets it terminate correctly.

It will certainly be useful in most cases to use the instruction keyboard.wait() in order to avoid an abrupt termination of your script.

If you wish to use procedures (local or private) it will be necessary to declare them at the end of your script AFTER the instruction script.stop().

The same holds true for any includes you want to read into your main script.

For example :

screen.resolution.set(320,240)
...
keyboard.wait()
script.stop()
procedure testing()
...
endprocedure
#include testing_include.tv

The syntax of actions on objects

As would seem logical, a script must download any audio or video AVO before it can use it.

Keeping this in mind, you have two options for how to work with AVOs.

The first way is to use a simple syntax which lets you display, for example, an image without having to go through the steps of asking the script to download it first.

Example

picture.display ("sky.jpg",center,center)

This instruction downloads and displays the image.
Useful when you don't want to modify your image in real time or if you only need to use it once.
In advanced syntax, you can download your image and THEN display it thanks to the use of an objectID.

Example

@pic=picture.load ("sky.jpg")
picture.display (@pic,center,center)

These two examples, though different in the means they employ, will result in exactly the same result.


The syntax of interacting with objects

The creation of an event (a color change, a rotation, etc.) must be done in general before the creation of the object on which this event is meant to take action.

There are two kinds of interaction in Alambik Script 4.0.

Instructions ending in ".set" are unique interaction instructions. That is to say, they only act once and they only act on the object directly preceding them in the script.

@m1=material.create ()
material.color.set (@m1,MATERIAL_DIFFUSECOLOR,%r,%g,%b)
material.alpha.mode.set (@m1,MATERIAL_ALPHABLEND)
material.alpha.level.set (@m1,127)

Here the different actions apply only to the material belonging to the object named @m1

Instructions ending in ".select" (as for .stack ones) are multiple interaction instructions. They act on all the objects which follow them.

box.color.select (0,0,0)
box.display (80,80,130,120)
box.display (70,80,120,130)
box.display (60,80,110,130)
box.display (50,80,130,110)

All of the boxes here will display in black.