MScript is a language for writing scripts for ICs in Stationeers. Stationeers uses an assembler based language (a variant of MIPS) to program ICs. This can make writing scripts extremely tedious and hard to understand/document/reuse. This project aims to fix this by introducing a higher level language that compiles to Stationeers Mips.
To build the program use eclipse or follow the following instructions (Linux).
- Clone project and cd into the folder
git clone https://github.com/The127/MScript.git
cd MScript
- Run the build script in the root folder of the project:
./build.sh
This will do the following:
- Compile the Java code using ANT
- Copy the ANTLR library and license informations into the bin folder, extract it and remove not needed files (ANTLR library is in the lib folder and may have another version number)
- Create the jar and copy it to the root folder
Now you should have the MScript.jar in the projects root folder.
Examples can be found under the examples folder.
A guide for the language can be found here.
To compile a MScript file use
java -jar MScript.jar ./res/test.ms
or more generally
java -jar MScript.jar <file>
MScript is inspired by other high level (namely python, rust and c).
The following example is a basic solar angle automation script.
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;
}
This will result in the following:
push ra
l r4 d0 SolarAngle
jal 25
push r4
push 1
jal 22
jal 12
jal 31
pop r4
s db Setting r4
yield
j 1
push ra
push r0
push 100.0
jal 38
push 180.0
jal 42
pop r4
pop r14
push r4
j r14
pop r1
pop r0
j ra
push r0
push r1
push r2
push r3
push r4
j ra
pop r12
pop r4
pop r3
pop r2
pop r1
pop r0
j 45
pop r13
pop r12
mul r12 r12 r13
j 45
pop r13
pop r12
div r12 r12 r13
push r12
j ra
Note that you still need to place your physical items accordingly.