Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 2.69 KB

README.md

File metadata and controls

44 lines (32 loc) · 2.69 KB

Simple Rockets 2 Compiler

javadoc

This compiler allows you to define Simple Rockets 2 spacecraft flight programs using a Scala 3 DSL.

Prerequisites

  1. Simple Rockets 2 installed
  2. Scala CLI installed
  3. Basic command line skills

Usage

Create a new file Hello.sc with the following content:

//> using scala "3.1.1"
//> using lib "com.akmetiuk::simple-rockets-compiler:0.1.1"
import rocketscompiler.{ *, given }

program("Hello") {
  displayText("Liftoff!")
  activateStage()
  Throttle := 1
}

Run scala-cli Hello.sc. This will convert the script into the Simple Rockets 2 program and write it to the game.

Next, from the game, open whatever craft you want to execute the project on. Click the menu button at the top-left of the screen, click "Edit Program". From the program editor, click the menu button again, select "Load Program". Find the "Hello" program and load it.

Possible Issues

Sometimes when you compile a script as described above, you may not find the program in Simple Rockets. Chances are the DSL failed at detecting the directory where Simple Rockets looks for programs correctly. If that is the case, you need to manually find out the location (e.g. described here). Then figure out where the game store the flight programs in that directory, by default should be UserData/FlightPrograms/ relative to the game directory.

Once you have the directory, you can explicitly specify it when writin a program as follows: program("Hello", java.io.File("/path/to/your/dir"))

Documentation

The scripting language is still a work in progress, so not everything is ported yet from the game's built-in language. See the complete list of what's available here.

Workshop

Following are some materials to organise the Scala in Science workshop: