Added documentation for various language features and in-game functions. Added example scripts
This commit is contained in:
75
README.md
75
README.md
@@ -1,30 +1,45 @@
|
||||
# Stationeers Language (slang)
|
||||
|
||||
This is an ambitious attempt at creating:
|
||||
|
||||
- A new programming language (slang)
|
||||
- A compiler to translate slang -> IC10
|
||||
- A mod to allow direct input of slang in the in-game script editor to
|
||||
automatically compile to IC10 before running
|
||||
|
||||
This project currently outputs 3 files:
|
||||
|
||||
- A Linux CLI
|
||||
- A Windows CLI
|
||||
- A Windows FFI dll
|
||||
- Contains a single function: `compile_from_string`
|
||||
|
||||
The aim of this project is to lower the amount of time it takes to code simple
|
||||
scripts in Stationeers so you can get back to engineering atmospherics or
|
||||
whatever you are working on. This project is NOT meant to fully replace IC10.
|
||||
Obviously hand-coded assembly written by an experienced programmer is more
|
||||
optimized and smaller than something that a C compiler will spit out. This is
|
||||
the same way. It WILL produce valid IC10, but for large complicated projects it
|
||||
might produce over the allowed limit of lines the in-game editor supports.
|
||||
|
||||
Current Unknowns
|
||||
|
||||
- Should I support a configurable script line length in-game to allow larger
|
||||
scripts to be saved?
|
||||
- Should compilation be "behind the scenes" (in game editor will ALWAYS be what
|
||||
you put in. IC10 will be IC10, slang will be slang)
|
||||
# Slang Language Documentation
|
||||
|
||||
Slang is a high-level programming language that compiles to IC10 assembly for [Stationeers](https://store.steampowered.com/app/544550/Stationeers/).
|
||||
It provides a familiar C-like syntax while targeting the limited instruction set
|
||||
of in-game IC10.
|
||||
|
||||
## Quick Links
|
||||
|
||||
- [Getting Started](docs/getting-started.md) - Installation and first program
|
||||
- [Language Reference](docs/language-reference.md) - Complete syntax guide
|
||||
- [Built-in Functions](docs/builtins.md) - System calls and math functions
|
||||
- [Examples](docs/examples.md) - Real-world code samples
|
||||
|
||||
## Overview
|
||||
|
||||
Slang aims to reduce the time spent writing IC10 assembly by providing:
|
||||
|
||||
- **Familiar syntax** - C-like declarations, control flow, and expressions
|
||||
- **Device abstraction** - Named device bindings with property access
|
||||
- **Automatic register allocation** - No manual register management
|
||||
- **Built-in functions** - Math operations and device I/O as function calls
|
||||
- **Temperature literals** - Native support for Celsius, Fahrenheit, and Kelvin
|
||||
|
||||
## Example
|
||||
|
||||
```mips
|
||||
device gasSensor = "d0";
|
||||
device airCon = "d1";
|
||||
|
||||
const TARGET_TEMP = 20c;
|
||||
|
||||
loop {
|
||||
yield();
|
||||
airCon.On = gasSensor.Temperature > TARGET_TEMP;
|
||||
}
|
||||
```
|
||||
|
||||
This compiles to IC10 that monitors temperature and controls an air
|
||||
conditioner.
|
||||
|
||||
## Project Status
|
||||
|
||||
Slang is under active development. It may produce suboptimal code for complex programs.
|
||||
It is not a replacement for IC10, for performance-critical or large scripts,
|
||||
hand-written IC10 may still be preferred.
|
||||
|
||||
Reference in New Issue
Block a user