BSL:Statements

From OniGalore
(Difference between revisions)
Jump to: navigation, search
m (Statement separators: OSL to BSL)
m (+cat)
 
Line 59: Line 59:
 
===var and func===
 
===var and func===
 
Those can also be viewed as special statements.
 
Those can also be viewed as special statements.
 +
 +
[[Category:Bungie scripting language docs]]

Latest revision as of 23:15, 16 May 2011

Contents

[edit] Basic statements

[edit] 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")

[edit] 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)

[edit] Special statements

[edit] 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.

[edit] if ... else ...

I'll take care of that one.

[edit] var and func

Those can also be viewed as special statements.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox