Skip to content

MScript

A compiler for the programmable chips in the space game Stationeers. It turns a small C-like language into their MIPS-style assembly.

The problem

In Stationeers (opens in a new tab) you program chips in a variant of MIPS assembly. That makes scripts tedious to write and hard to read or reuse.

How it works

MScript is a small language inspired by Python, Rust and C, with variables, functions, loops and named devices. The compiler is written in Java with ANTLR and turns it into the game's assembly.

Status

Not actively developed. The last change was in January 2024.

Try it

This script reads the sun's angle and turns a solar panel to match it:

def db as base;
def d0 as SolarSensor;

def $RotationDegrees as 100;
def $SolarDegrees as 180;

fn main (){
	var winkel;
	loop {
		read SolarSensor.SolarAngle into winkel;
		winkel = calc(winkel, 1);
		write winkel into base.Setting;
		yield;
	}
}

fn calc(winkel, b) {
	var result;
	result = winkel * $RotationDegrees / $SolarDegrees;
	return result;
}