Commands
All ScratchIR commands are defined in the ANTLR4 grammar itself.
It can be separated into 5 categories:
Data
load
load(:type) (name) or load:number x
Adds a variable with the specified type and name to the Scratch project. Must be called before set.
set
set var:(name) (expression) or set var:x 1
Sets a value to the variable with the specified name.
Control flow
while
while (expression) ... end or while (> 2 1) ... end
Executes commands until the expression becomes false.
repeat
repeat (expression/times) ... end or repeat 5 ... end
Executes commands exactly times times. The expression must evaluate to a number.
if
if (condition) ... end (else if (condition2) ... end)? (else ... end)? or if == 1 1 ... end else ...? end
Executes commands conditionally. All conditions must evaluate to booleans.
Procedures
call
call (function) or call __Exponent
Calls the function with the specified name. All function arguments must be pushed before calling it.
raw
raw (name) (fields/inputs) or raw data_deleteoflist f:LIST:\"__Stack\" i:INDEX:0
Creates a native Scratch block. Fields are specified via f:NAME:VALUE and inputs are specified via i:NAME:VALUE.
Lists
push
push (name) (expression) or push __Stack 1
Pushes a value to a list with the specified name.
pushat
pushat (name) (index) (expression) or push __Stack 1 2
Pushes a value to a specific place in a list with the specified name.
pop
pop (name) or pop __Stack
Pops a value from a list with the specified name (without returning it).
popat
pop (name) (index) or pop __Stack 1
Pops a value in a specific place from a list with the specified name (without returning it).
popall
popall (name) or popall __Stack
Pops all values from a list with the specified name (basically clears it).
Procedures/Events
Procedures are defined via proc in the following syntax:
:w means a function runs without screen refresh. :sn and :b indicate the type of the argument (string/number or boolean).
Events are defined via on: