Rocket Script (RS) - Language Reference

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.

Table of Contents

Basic Movement Commands

FORCE

Applies continuous thrust for a specified duration.

Syntax: FORCE <power> <duration>

FORCE 10 3

Applies thrust with power 10 for 3 seconds.

IMPULSE

Applies an instant burst of force in the rocket's current direction.

Syntax: IMPULSE <power>

IMPULSE 15

Instant boost with power 15.

ROTATE

Rotates the rocket to a specified angle.

Syntax: ROTATE <degrees>

ROTATE 45 ROTATE -90 ROTATE 0

WAIT

Pauses execution for a specified duration.

Syntax: WAIT <seconds>

WAIT 2

Wait for 2 seconds before executing the next command.

Example: Basic Flight

IMPULSE 10 ROTATE -45 FORCE 5 1 ROTATE 45 FORCE 3 1
Important: You can finish all 3 levels only with the basic movement commands above! Everything from variables to telemetry sensors are "extras" that more experienced programmers or players can experiment with in the test level.

Conditional Statements

IF with ELSE

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

Comparison Operators

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

Example: Conditional Actions

IF ground_distance < 15 ROTATE 0 IMPULSE 10 END

Example: IF-ELSE Logic

IF water_distance < 20 IMPULSE 15 // Boost away from water ELSE FORCE 10 1 // Normal thrust END

Loop Statements

LOOP

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.

Example: Repeated Actions

LOOP 5 IMPULSE 10 WAIT 0.5 END

Executes the impulse and wait commands 5 times.

WHILE

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.

Example: Conditional Looping

WHILE altitude < 50 FORCE 10 0.5 WAIT 0.2 END

Continues thrusting until altitude reaches 50.

Variables

SET

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.

Example: Reusable Values

SET power = 12 SET turn = 30 IMPULSE power WAIT 1 ROTATE turn FORCE power 2 ROTATE -turn FORCE power 2

Parachute System

NEW: Control the rocket's parachute for safe landings

PARACHUTEON

Deploys the parachute to slow descent.

Syntax: PARACHUTEON

PARACHUTEON

Deploys parachute immediately.

PARACHUTEOFF

Undeploys the parachute.

Syntax: PARACHUTEOFF

PARACHUTEOFF

Removes parachute immediately.

Example: Safe Landing

WHILE ground_distance > 30 FORCE 8 0.5 WAIT 0.3 END IF velocity > 15 PARACHUTEON WAIT 2 END

Example: Emergency Parachute

WHILE altitude > 10 IF velocity > 25 OR ground_distance < 20 PARACHUTEON END WAIT 0.1 END

Telemetry Sensors

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
Warning: Contact with water results in instant rocket destruction!

Example: Sensor-Based Navigation

WHILE altitude < 40 FORCE 10 0.5 WAIT 0.2 END IF velocity > 30 ROTATE 180 IMPULSE 5 END

Logical Operators

Multiple conditions can be combined using logical operators for complex decision making.

AND

Both conditions must be true for the entire expression to be true.

IF ground_distance < 20 AND velocity < 5 ROTATE 0 IMPULSE 3 END

OR

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

Example: Complex Landing Logic

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

Example: Multi-Hazard Navigation

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

Syntax Quick Reference

Commands

FORCE <power> <duration> IMPULSE <power> ROTATE <degrees> WAIT <seconds> SET <variable> = <value> PARACHUTEON PARACHUTEOFF

Control Structures

LOOP <iterations> // commands END WHILE <condition> // commands END IF <condition> // commands ELSE // commands END

Conditions

<sensor> <operator> <value> <condition> AND <condition> <condition> OR <condition>

Sensors

altitude velocity angle ground_distance water_distance

Operators

< less than > greater than <= less than or equal >= greater than or equal == equal to != not equal to AND logical and OR logical or

Comments

// This is a comment // Comments are ignored during execution

Important Notes