Compiles code into scratch projects.
If you've ever used Python, you will probably find the syntax familiar.
stage:
...
There can only be one stage. It can contain variables, lists, costumes and procedures.
sprite name_of_sprite:
...
You can create as many sprites as you want. Sprites can, just like the stage, contain variables lists, costumes and procedures.
costumes {
"costume1.png", "costume2.svg"
}
Sprites and the stage contain a list of costumes. The costumes are referred to by their file names.
foo : var
Declares a variable named foo
. Variables can either be declared in the global
scope or in a sprite.
foo = 5
Assign a value to a variable.
foo += 10
foo -= 10
foo *= 10
foo /= 10
These statements are equivalent to the following:
foo = foo + 10
foo = foo - 10
foo = foo * 10
foo = foo / 10
lst : list
Declares a list named lst
.
lst[n]
Returns the n
th element of lst
. List indices start at 1.
lst += value
Appends value
to the end of lst
.
lst.append(value)
Appends value
to the end of lst
.
lst.clear()
Removes all elements from lst
.
lst.insert(index, value)
Inserts value
at index
in lst
.
TODO: Add more list function and procedures.
def my_procedure(a, b, c):
doSomething()
doSomethingElse()
Creates the procedure my_procedure
that takes the arguments a
, b
and
c
. When called, it will run the indented code block. Procedures can belong to
sprites or the stage.
warp def render():
...
The warp
keyword applies "run without screen refresh" to a procedure.
if a_condition:
doSomething()
Run doSomething()
if a_condition
is true.
if a_condition:
branch1()
else:
branch2()
Run branch1()
if a_condition
is true, otherwise run branch2()
.
if a_condition:
branch1()
elif another_condition:
branch2()
Run branch1()
if a_condition
is true. If it's not true, continue down and
run branch2()
if another_condition
is true. elif
s can be chained and the
chain can optionally end with an else
that will run if all of the conditions
fail.