BSL:Statements

From OniGalore
Revision as of 23:15, 16 May 2011 by Iritscen (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Basic statements

Statement separators

BSL accepts 2 statement separators : the semicolon (;) and the linebreak. The following pieces of code are equivalent :

dmsg("Statement 1"); dmsg("Statement 2");

and

dmsg("Statement 1")
dmsg("Statement 2")

Compound statements

Compound statements are groups of statements held together by a pair of 'braces' An example that uses the linebreak separator :

{
dmsg("Statement 1")
dmsg("Statement 2")
dmsg("Statement 3")
}

and one that uses the semicolon :

{dmsg("Statement 1"); dmsg("Statement 2"); dmsg("Statement 3");}

The row of statements between the braces is then treated as a single statement.

This is useful when you want to treat some (possibly big) piece of logic as a whole.

For example, you may want to execute a block of statements only if some condition is fulfilled.

STATEMENT1
STATEMENT2
if(CONDITION) {
    STATEMENT3
    STATEMENT4
}
STATEMENT5

(See "Special statements" below for details on if)

Or, you may want to completely separate some statements from the rest by making them into a function.

STATEMENT1
STATEMENT2
if(CONDITION) Function
STATEMENT5
...
func Function {
    STATEMENT3
    STATEMENT4
}

(See function declaration for details)

Special statements

sleep

The 'sleep' command tells the game to wait for a defined duration before executing the lines of code that follow.

Format: sleep duration:int

Eg: sleep 200

Note that sleep 60 is equivalent to 1 second.

if ... else ...

I'll take care of that one.

var and func

Those can also be viewed as special statements.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox