Rocket Script is a simple programming language for controlling the rocket inside Rocket Commander. Write commands, run them and watch your rocket follow your instructions.
The goal is to learn the very basics of the logic behind programming.
Created by: Albert Freeman | albertfreeman.org
Note: The code isn't case sensitive.
Copy and paste (control c + control v) works. You can undo with control + z and redo with control + shift + z.
Applies continuous thrust for a specified duration.
Syntax: FORCE <power> <duration>
FORCE 10 3
Applies thrust with power 10 for 3 seconds.
Applies an instant burst of force in the rocket's current direction.
Syntax: IMPULSE <power>
IMPULSE 15
Instant boost with power 15.
Rotates the rocket to a specified angle.
Syntax: ROTATE <degrees>
ROTATE 45
ROTATE -90
ROTATE 0
Pauses execution for a specified duration.
Syntax: WAIT <seconds>
WAIT 2
Wait for 2 seconds before executing the next command.
IMPULSE 10
ROTATE -45
FORCE 5 1
ROTATE 45
FORCE 3 1
Executes a block of commands only if a condition is true, with optional alternative commands.
Syntax:
IF <condition>
// commands if true
ELSE
// commands if false
END
Operator | Description | Example |
---|---|---|
< | Less than | velocity < 10 |
> | Greater than | altitude > 50 |
<= | Less than or equal to | ground_distance <= 15 |
>= | Greater than or equal to | velocity >= 5 |
== | Equal to | angle == 0 |
!= | Not equal to | altitude != 0 |
IF ground_distance < 15
ROTATE 0
IMPULSE 10
END
IF water_distance < 20
IMPULSE 15 // Boost away from water
ELSE
FORCE 10 1 // Normal thrust
END
Repeats a block of commands a fixed number of times.
Syntax:
LOOP <iterations>
// commands
END
All commands between LOOP and END will be executed the specified number of times.
LOOP 5
IMPULSE 10
WAIT 0.5
END
Executes the impulse and wait commands 5 times.
Repeats a block of commands while a condition remains true.
Syntax:
WHILE <condition>
// commands
END
The condition is checked before each iteration. If false, the loop exits.
Safety limit: WHILE loops automatically stop after 1000 iterations to prevent infinite loops.
WHILE altitude < 50
FORCE 10 0.5
WAIT 0.2
END
Continues thrusting until altitude reaches 50.
Creates a variable and assigns a value to it. Variables can be used in place of numeric values in any command.
Syntax: SET <variable_name> = <value>
SET thrust = 15
SET angle = 45
SET delay = 1.5
ROTATE angle
FORCE thrust 2
WAIT delay
Variable names can contain letters, numbers, and underscores. They cannot start with a number.
SET power = 12
SET turn = 30
IMPULSE power
WAIT 1
ROTATE turn
FORCE power 2
ROTATE -turn
FORCE power 2
Deploys the parachute to slow descent.
Syntax: PARACHUTEON
PARACHUTEON
Deploys parachute immediately.
Undeploys the parachute.
Syntax: PARACHUTEOFF
PARACHUTEOFF
Removes parachute immediately.
WHILE ground_distance > 30
FORCE 8 0.5
WAIT 0.3
END
IF velocity > 15
PARACHUTEON
WAIT 2
END
WHILE altitude > 10
IF velocity > 25 OR ground_distance < 20
PARACHUTEON
END
WAIT 0.1
END
The rocket has built-in sensors that provide real-time data. These values can be used in conditions.
Sensor | Description | Unit |
---|---|---|
altitude | Current height above starting position | meters |
velocity | Current speed (magnitude of velocity vector) | m/s |
angle | Direction rocket is facing (0 = up) | degrees |
ground_distance | Distance to ground directly below rocket | meters |
water_distance | Distance to water directly below rocket | meters |
WHILE altitude < 40
FORCE 10 0.5
WAIT 0.2
END
IF velocity > 30
ROTATE 180
IMPULSE 5
END
Multiple conditions can be combined using logical operators for complex decision making.
Both conditions must be true for the entire expression to be true.
IF ground_distance < 20 AND velocity < 5
ROTATE 0
IMPULSE 3
END
At least one condition must be true for the entire expression to be true.
WHILE ground_distance < 20 OR water_distance < 20
IMPULSE 10
WAIT 0.1
END
LOOP 40
IF ground_distance < 15 AND velocity < 8 AND angle < 10
ROTATE 0
FORCE 10 0.5
END
IF water_distance < 12 OR ground_distance < 8
IMPULSE 15
END
WAIT 0.2
END
WHILE altitude < 50 OR velocity < 20
IF water_distance > 25 AND ground_distance > 25
FORCE 12 0.5
END
IF water_distance < 15 OR ground_distance < 15
IMPULSE 10
END
WAIT 0.2
END
FORCE <power> <duration>
IMPULSE <power>
ROTATE <degrees>
WAIT <seconds>
SET <variable> = <value>
PARACHUTEON
PARACHUTEOFF
LOOP <iterations>
// commands
END
WHILE <condition>
// commands
END
IF <condition>
// commands
ELSE
// commands
END
<sensor> <operator> <value>
<condition> AND <condition>
<condition> OR <condition>
altitude
velocity
angle
ground_distance
water_distance
< less than
> greater than
<= less than or equal
>= greater than or equal
== equal to
!= not equal to
AND logical and
OR logical or
// This is a comment
// Comments are ignored during execution