There are seven variable types in FlareScript :
nil, boolean, number, string, table, function, object
Nil represents the type of the value
nil, whose main property is to be different than any other value.
Boolean is the type of values
false and
true.
Both
nil and
false make a condition fail, any other values makes a condition succeed.
Number represents double precision floating point numbers. Numbers are often converted to strings automatically when necessary.
String represents an array of 8-bit characters delimited by ' or "
^ is used for literal string escape sequences... eg. "^13", carriage return
[[...]] can be used for breaking literal strings across multiple lines.
Table represents a flexible associative array structure.
Tables are created using {...}
t = {10,20}
t = {x=10,y=20}
Element definitions can optionally be delimited by semicolons.
Function represent functions as defined with
function (
parameters )
block end
function sum(x,y)
return x+y
end
Object represents an instance of an ImageFlare API class
Single line and multiline comments are provided in C/C++ syntax. However, multiline comments can be nested in FlareScript.
// this is a single line comment
/*
multiline
comment
*/
while condition do block end
repeat block until condition
if condition then block {
elseif condition then block } [
else block ]
end
The return statement is used to return values from a function or chunk. The return statement
can return multiple values.
The break statement is used to terminate the execution of a while, repeat, or for loop,
skipping to the next statement after the loop.
For syntactic reasons, return and break statements can only be written as the last statement of a block.
If it is really necessary to return or break in the middle of a block, then an explicit inner block can
be used.
for variable=
init,
limit [,
step]
do block end
Notes :
The default step is 1
Limit and step are evaluated once before the loop starts
Do not assign to variable inside the loop (maybe you want while)
You can use break to exit a for loop
The loop variable is local to the statement and not accessible after breaking or exiting the loop
If you need the value of variable outside the loop, assign it to another variable before leaving the loop
Examples :
for i=0, 100 do
...
end
for i=0, -270, -1.618 do
...
end