@@ -1,40 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ModMetadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<Name>StationeersSlang</Name>
|
||||
<Author>JoeDiertay</Author>
|
||||
<Version>0.1.0</Version>
|
||||
<Description>
|
||||
Slang (Stationeers Language) is a high-level programming language that compiles directly into IC10 within the game.
|
||||
<ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Name>StationeersSlang</Name>
|
||||
<Author>JoeDiertay</Author>
|
||||
<Version>0.1.1</Version>
|
||||
<Description>
|
||||
[h1]Slang: High-Level Programming for Stationeers[/h1]
|
||||
|
||||
Features:
|
||||
- In-Game Compilation: Write C-style code directly in the IC editor.
|
||||
- Automatic Register Management: Define variables with 'let' (e.g., let x = 10) without managing r0-r15.
|
||||
- Standard Control Flow: Use if/else, while, loop, break, and continue.
|
||||
- Functions: Define and call functions with arguments.
|
||||
- Smart Editor: Real-time syntax highlighting and error checking (red text for errors).
|
||||
- Persistent Source: Your high-level source code is saved inside the chip data, so you can edit it later.
|
||||
- Constant Folding: Mathematical operations on constants are calculated at compile time to save instructions.
|
||||
- Device Aliasing: Easy device mapping (e.g., device sensor = "d0").
|
||||
Stop writing assembly. Start writing code.
|
||||
|
||||
Installation:
|
||||
This is a StationeersLaunchPad Plugin Mod. It requires BepInEx to be installed.
|
||||
Slang (Stationeers Language) brings modern programming to Stationeers. It allows you to write scripts using a familiar C-style syntax (variables, functions, if/else, loops) directly in the in-game editor. When you hit confirm, Slang compiles your code into IC10 instantly.
|
||||
|
||||
Usage:
|
||||
1. Open any IC10 housing or editor.
|
||||
2. Write Slang code.
|
||||
3. Press Confirm to compile and run.
|
||||
</Description>
|
||||
<Tags>
|
||||
<Tag>Logic</Tag>
|
||||
<Tag>Scripting</Tag>
|
||||
<Tag>Code</Tag>
|
||||
<Tag>BepInEx</Tag>
|
||||
<Tag>StationeersLaunchPad</Tag>
|
||||
<Tag>Quality of Life</Tag>
|
||||
</Tags>
|
||||
<InGameDescription><![CDATA[
|
||||
[b]NOTE: This project is in BETA. Expect updates and changes![/b]
|
||||
|
||||
[h2]Features[/h2]
|
||||
[list]
|
||||
[*] [b]In-Game Compilation:[/b] No external tools needed. Write Slang directly in the IC editor.
|
||||
[*] [b]No More Register Juggling:[/b] Define variables with let (e.g., let temp = 300). The compiler manages r0-r15 for you.
|
||||
[*] [b]Control Flow:[/b] Write readable logic with if, else, while, loop, break, and continue.
|
||||
[*] [b]Functions:[/b] Create reusable code blocks with arguments.
|
||||
[*] [b]Smart Editor:[/b] Get real-time syntax highlighting and error checking (red text) as you type.
|
||||
[*] [b]Persistent Source:[/b] Your high-level Slang code is saved to the chip, so it's there when you come back.
|
||||
[*] [b]Optimizations:[/b] Features like Constant Folding calculate math at compile time to save instructions.
|
||||
[*] [b]Device Aliasing:[/b] Simple mapping: device sensor = "d0".
|
||||
[*] [b]Temperature Literals:[/b] Don't worry about converting Celsius to Kelvin anymore. Define your temperatures as whatever you want and append the proper suffix at the end (ex. 20c, 68f, 293.15k)
|
||||
[/list]
|
||||
|
||||
[h2]Installation[/h2]
|
||||
This is a StationeersLaunchPad Plugin Mod.
|
||||
1. Install BepInEx (required).
|
||||
2. Install StationeersLaunchPad.
|
||||
3. Subscribe to Slang.
|
||||
|
||||
[h2]Usage[/h2]
|
||||
1. Open any IC10 housing or editor in-game.
|
||||
2. Write your Slang code.
|
||||
3. Press [b]Confirm[/b]. The mod compiles your code to IC10 and loads it onto the chip.
|
||||
|
||||
[h2]Example Code[/h2]
|
||||
[code]
|
||||
device airCon = "d0";
|
||||
device gasSensor = "d1";
|
||||
|
||||
loop {
|
||||
yield();
|
||||
// yes, ideally you would use a latch here, but this is just a simple example :)
|
||||
airCon.On = gasSensor.Temperature >= 28c;
|
||||
}
|
||||
[/code]
|
||||
|
||||
[h2]Known Issues (Beta)[/h2]
|
||||
[list]
|
||||
[*] [b]Code Size:[/b] Compiled output is currently more verbose than hand-optimized assembly. Optimization passes are planned.
|
||||
[*] [b]Stack Access:[/b] Direct stack memory access is disabled to prevent conflicts with the compiler's internal memory management.
|
||||
[*] [b]Documentation:[/b] In-game tooltips for syscalls (like load, set) are WIP. Check the "Slang" entry in the Stationpedia (F1) for help.
|
||||
[*] [b]Debugging:[/b] Runtime errors currently point to the compiled IC10 line number, not your Slang source line. Source mapping is coming soon.
|
||||
[/list]
|
||||
|
||||
[h2]Planned Features[/h2]
|
||||
[list]
|
||||
[*] Side-by-side view: Slang vs. Compiled IC10.
|
||||
[*] Compiler optimizations (dead code elimination, smarter register allocation).
|
||||
[*] Enhanced LSP features (Autocomplete, Go to Definition).
|
||||
[*] Full feature parity with all IC10 instructions.
|
||||
[*] Tutorials and beginner script examples.
|
||||
[/list]
|
||||
|
||||
[h2]FAQ[/h2]
|
||||
[b]Q: What is the DLL extracted to my temp folder?[/b]
|
||||
A: The Slang compiler is built in Rust for performance and reliability. It is compiled as a native library and bundled with the mod. It must be extracted temporarily to function within the game's C# environment.
|
||||
|
||||
[b]Q: Is this compatible with my current save?[/b]
|
||||
A: Yes! Slang does not modify any existing IC10 code, it is only a compiler. As a matter of fact: if you wish to stop using Slang at any time, your compiled IC10 will still exist on the chip. However: Slang adds a comment at the bottom of your compiled IC10 which is a GZIP and base64 encoded version of your Slang source code. This might break line limits with Slang not installed. If you wish to no longer use Slang, I recommend you remove this comment from the source code after uninstalling Slang.
|
||||
|
||||
[h2]Useful Links[/h2]
|
||||
[url=https://github.com/dbidwell94/stationeers_lang]Source Code on GitHub[/url]
|
||||
[url=https://discord.gg/stationeers]Stationeers Official Discord[/url]
|
||||
[url=https://discord.gg/M4sCfYMacs]Stationeers Modding Discord[/url]
|
||||
</Description>
|
||||
<ChangeLog xsi:nil="true" />
|
||||
<WorkshopHandle>3619985558</WorkshopHandle>
|
||||
<Tags>
|
||||
<Tag>Logic</Tag>
|
||||
<Tag>Scripting</Tag>
|
||||
<Tag>Code</Tag>
|
||||
<Tag>BepInEx</Tag>
|
||||
<Tag>StationeersLaunchPad</Tag>
|
||||
<Tag>Quality of Life</Tag>
|
||||
</Tags>
|
||||
<DependsOn WorkshopHandle="3592775931" />
|
||||
<OrderBefore WorkshopHandle="3592775931" />
|
||||
<InGameDescription><![CDATA[
|
||||
<size=30><color=#ffff00>Slang - High Level Language Compiler</color></size>
|
||||
A modern programming experience for Stationeers. Write C-style code that compiles to MIPS assembly instantly.
|
||||
A modern programming experience for Stationeers. Write C-style code that compiles to IC10 instantly.
|
||||
|
||||
<color=#ffa500><b>Features</b></color>
|
||||
- <b>In-Game Compilation:</b> Write high-level logic directly in the chip editor.
|
||||
@@ -61,10 +118,5 @@
|
||||
See: https://github.com/StationeersLaunchPad/StationeersLaunchPad
|
||||
|
||||
Source Code: https://github.com/dbidwell94/stationeers_lang
|
||||
]]>
|
||||
</InGameDescription>
|
||||
<Dependencies>
|
||||
<Dependency>IC10Editor</Dependency>
|
||||
</Dependencies>
|
||||
<LoadAfter>IC10Editor</LoadAfter>
|
||||
]]></InGameDescription>
|
||||
</ModMetadata>
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Slang
|
||||
{
|
||||
public const string PluginGuid = "com.biddydev.slang";
|
||||
public const string PluginName = "Slang";
|
||||
public const string PluginVersion = "0.1.0";
|
||||
public const string PluginVersion = "0.1.1";
|
||||
|
||||
public static Mod MOD = new Mod(PluginName, PluginVersion);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>StationeersSlang</AssemblyName>
|
||||
<Description>Slang Compiler Bridge</Description>
|
||||
<Version>0.1.0</Version>
|
||||
<Version>0.1.1</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
2
rust_compiler/Cargo.lock
generated
2
rust_compiler/Cargo.lock
generated
@@ -843,7 +843,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "slang"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "slang"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
[workspace]
|
||||
|
||||
@@ -9,97 +9,97 @@ documented! {
|
||||
/// ## IC10
|
||||
/// `acos r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).acos();`
|
||||
/// `let item = acos(number|var|expression);`
|
||||
Acos(Box<Spanned<Expression>>),
|
||||
/// Returns the angle in radians whose sine is the specified number.
|
||||
/// ## IC10
|
||||
/// `asin r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).asin();`
|
||||
/// `let item = asin(number|var|expression);`
|
||||
Asin(Box<Spanned<Expression>>),
|
||||
/// Returns the angle in radians whose tangent is the specified number.
|
||||
/// ## IC10
|
||||
/// `atan r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).atan();`
|
||||
/// `let item = atan(number|var|expression);`
|
||||
Atan(Box<Spanned<Expression>>),
|
||||
/// Returns the angle in radians whose tangent is the quotient of the specified numbers.
|
||||
/// ## IC10
|
||||
/// `atan2 r? a(r?|num) b(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).atan2((number|var));`
|
||||
/// `let item = atan2((number|var|expression), (number|var|expression));`
|
||||
Atan2(Box<Spanned<Expression>>, Box<Spanned<Expression>>),
|
||||
/// Gets the absolute value of a number.
|
||||
/// ## IC10
|
||||
/// `abs r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).abs();`
|
||||
/// `let item = abs((number|var|expression));`
|
||||
Abs(Box<Spanned<Expression>>),
|
||||
/// Rounds a number up to the nearest whole number.
|
||||
/// ## IC10
|
||||
/// `ceil r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).ceil();`
|
||||
/// `let item = ceil((number|var|expression));`
|
||||
Ceil(Box<Spanned<Expression>>),
|
||||
/// Returns the cosine of the specified angle in radians.
|
||||
/// ## IC10
|
||||
/// `cos r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).cos();`
|
||||
/// `let item = cos((number|var|expression));`
|
||||
Cos(Box<Spanned<Expression>>),
|
||||
/// Rounds a number down to the nearest whole number.
|
||||
/// ## IC10
|
||||
/// `floor r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).floor();`
|
||||
/// `let item = floor((number|var|expression));`
|
||||
Floor(Box<Spanned<Expression>>),
|
||||
/// Computes the natural logarithm of a number.
|
||||
/// ## IC10
|
||||
/// `log r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).log();`
|
||||
/// `let item = log((number|var|expression));`
|
||||
Log(Box<Spanned<Expression>>),
|
||||
/// Computes the maximum of two numbers.
|
||||
/// ## IC10
|
||||
/// `max r? a(r?|num) b(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).max((number|var));`
|
||||
/// `let item = max((number|var|expression), (number|var|expression));`
|
||||
Max(Box<Spanned<Expression>>, Box<Spanned<Expression>>),
|
||||
/// Computes the minimum of two numbers.
|
||||
/// ## IC10
|
||||
/// `min r? a(r?|num) b(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).min((number|var));`
|
||||
/// `let item = min((number|var|expression), (number|var|expression));`
|
||||
Min(Box<Spanned<Expression>>, Box<Spanned<Expression>>),
|
||||
/// Gets a random number between 0 and 1.
|
||||
/// ## IC10
|
||||
/// `rand r?`
|
||||
/// ## Slang
|
||||
/// `rand();`
|
||||
/// `let item = rand();`
|
||||
Rand,
|
||||
/// Returns the sine of the specified angle in radians.
|
||||
/// ## IC10
|
||||
/// `sin r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).sin();`
|
||||
/// `let item = sin((number|var|expression));`
|
||||
Sin(Box<Spanned<Expression>>),
|
||||
/// Computes the square root of a number.
|
||||
/// ## IC10
|
||||
/// `sqrt r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).sqrt();`
|
||||
/// `let item = sqrt((number|var|expression));`
|
||||
Sqrt(Box<Spanned<Expression>>),
|
||||
/// Returns the tangent of the specified angle in radians.
|
||||
/// ## IC10
|
||||
/// `tan r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).tan();`
|
||||
/// `let item = tan((number|var|expression));`
|
||||
Tan(Box<Spanned<Expression>>),
|
||||
/// Truncates a number by removing the decimal portion.
|
||||
/// ## IC10
|
||||
/// `trunc r? a(r?|num)`
|
||||
/// ## Slang
|
||||
/// `(number|var).trunc();`
|
||||
/// `let item = trunc((number|var|expression));`
|
||||
Trunc(Box<Spanned<Expression>>),
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,9 @@ documented! {
|
||||
/// ## IC10
|
||||
/// `l r? d? var`
|
||||
/// ## Slang
|
||||
/// `load(deviceType, "LogicType");`
|
||||
/// `let item = load(deviceHash, "LogicType");`
|
||||
/// `let item = l(deviceHash, "LogicType");`
|
||||
/// `let item = deviceAlias.LogicType;`
|
||||
LoadFromDevice(Spanned<LiteralOrVariable>, Spanned<Literal>),
|
||||
/// Function which gets a LogicType from all connected network devices that match
|
||||
/// the provided device hash and name, aggregating them via a batchMode
|
||||
@@ -168,6 +170,7 @@ documented! {
|
||||
/// `lbn r? deviceHash nameHash logicType batchMode`
|
||||
/// ## Slang
|
||||
/// `loadBatchedNamed(deviceHash, deviceName, "LogicType", "BatchMode");`
|
||||
/// `lbn(deviceHash, deviceName, "LogicType", "BatchMode");`
|
||||
LoadBatchNamed(
|
||||
Spanned<LiteralOrVariable>,
|
||||
Spanned<LiteralOrVariable>,
|
||||
@@ -180,26 +183,31 @@ documented! {
|
||||
/// `lb r? deviceHash logicType batchMode`
|
||||
/// ## Slang
|
||||
/// `loadBatched(deviceHash, "Variable", "LogicType");`
|
||||
/// `lb(deviceHash, "Variable", "LogicType");`
|
||||
LoadBatch(Spanned<LiteralOrVariable>, Spanned<Literal>, Spanned<Literal>),
|
||||
/// Represents a function which stores a setting into a specific device.
|
||||
/// ## IC10
|
||||
/// `s d? logicType r?`
|
||||
/// ## Slang
|
||||
/// `set(deviceType, "Variable", (number|var));`
|
||||
/// `set(deviceHash, "LogicType", (number|var));`
|
||||
/// `s(deviceHash, "LogicType", (number|var));`
|
||||
/// `deviceAlias.LogicType = (number|var);`
|
||||
SetOnDevice(Spanned<LiteralOrVariable>, Spanned<Literal>, Box<Spanned<Expression>>),
|
||||
/// Represents a function which stores a setting to all devices that match
|
||||
/// the given deviceHash
|
||||
/// ## IC10
|
||||
/// `sb deviceHash logicType r?`
|
||||
/// ## Slang
|
||||
/// `setBatched(deviceHash, "LogicType", (number|var))`
|
||||
/// `setBatched(deviceHash, "LogicType", (number|var));`
|
||||
/// `sb(deviceHash, "LogicType", (number|var));`
|
||||
SetOnDeviceBatched(Spanned<LiteralOrVariable>, Spanned<Literal>, Box<Spanned<Expression>>),
|
||||
/// Represents a function which stores a setting to all devices that match
|
||||
/// both the given deviceHash AND the given nameHash
|
||||
/// ## IC10
|
||||
/// `sbn deviceHash nameHash logicType r?`
|
||||
/// ## Slang
|
||||
/// `setBatchedNamed(deviceHash, nameHash, "LogicType", (number|var))`
|
||||
/// `setBatchedNamed(deviceHash, nameHash, "LogicType", (number|var));`
|
||||
/// `sbn(deviceHash, nameHash, "LogicType", (number|var));`
|
||||
SetOnDeviceBatchedNamed(
|
||||
Spanned<LiteralOrVariable>,
|
||||
Spanned<LiteralOrVariable>,
|
||||
|
||||
Reference in New Issue
Block a user