From 1b96a17698a6d57f4c7da4152470000f636af59b Mon Sep 17 00:00:00 2001 From: Devin Bidwell Date: Sun, 7 Dec 2025 21:15:58 -0700 Subject: [PATCH] Update ModData/About.xml, update various syscalls in Stationpedia --- ModData/About/About.xml | 184 ++++++++++++++-------- csharp_mod/Plugin.cs | 2 +- csharp_mod/stationeersSlang.csproj | 2 +- rust_compiler/Cargo.lock | 2 +- rust_compiler/Cargo.toml | 2 +- rust_compiler/libs/parser/src/sys_call.rs | 48 +++--- 6 files changed, 146 insertions(+), 94 deletions(-) diff --git a/ModData/About/About.xml b/ModData/About/About.xml index 464e823..10c78ec 100644 --- a/ModData/About/About.xml +++ b/ModData/About/About.xml @@ -1,70 +1,114 @@ - - - StationeersSlang - JoeDiertay - 0.1.0 - - Slang (Stationeers Language) is a high-level programming language that compiles directly into IC10 within the game. - - 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"). - - Installation: - This is a StationeersLaunchPad Plugin Mod. It requires BepInEx to be installed. - - Usage: - 1. Open any IC10 housing or editor. - 2. Write Slang code. - 3. Press Confirm to compile and run. - - - Logic - Scripting - Code - BepInEx - StationeersLaunchPad - Quality of Life - - Slang - High Level Language Compiler - A modern programming experience for Stationeers. Write C-style code that compiles to MIPS assembly instantly. - - Features - - In-Game Compilation: Write high-level logic directly in the chip editor. - - Automatic Registers: Stop juggling r0-r15. Just use let variables. - - Control Flow: Full support for if, else, while, and loop. - - Smart Editor: Integrated syntax highlighting and real-time error checking. - - Persistent Code: Your Slang source code is saved with the chip, so you never lose your work. - - Optimization: The compiler automatically optimizes constant math (e.g., 1 + 2 becomes 3). - - Example Code - device sensor = "d0"; - const MAX_TEMP = 300k; - - loop { - let temp = sensor.Temperature; - if (temp > MAX_TEMP) { - // Do logic here - } - yield(); - } - - Installation - This is a StationeersLaunchPad Plugin Mod. It requires BepInEx to be installed. - See: https://github.com/StationeersLaunchPad/StationeersLaunchPad - - Source Code: https://github.com/dbidwell94/stationeers_lang - ]]> - - - IC10Editor - - IC10Editor - + + + StationeersSlang + JoeDiertay + 0.1.1 + + [h1]Slang: High-Level Programming for Stationeers[/h1] + + Stop writing assembly. Start writing code. + + 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 optimized IC10 MIPS assembly instantly. + + [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. + + + 3619985558 + + Logic + Scripting + Code + BepInEx + StationeersLaunchPad + Quality of Life + + + + Slang - High Level Language Compiler + A modern programming experience for Stationeers. Write C-style code that compiles to MIPS assembly instantly. + + Features + - In-Game Compilation: Write high-level logic directly in the chip editor. + - Automatic Registers: Stop juggling r0-r15. Just use let variables. + - Control Flow: Full support for if, else, while, and loop. + - Smart Editor: Integrated syntax highlighting and real-time error checking. + - Persistent Code: Your Slang source code is saved with the chip, so you never lose your work. + - Optimization: The compiler automatically optimizes constant math (e.g., 1 + 2 becomes 3). + + Example Code + device sensor = "d0"; + const MAX_TEMP = 300k; + + loop { + let temp = sensor.Temperature; + if (temp > MAX_TEMP) { + // Do logic here + } + yield(); + } + + Installation + This is a StationeersLaunchPad Plugin Mod. It requires BepInEx to be installed. + See: https://github.com/StationeersLaunchPad/StationeersLaunchPad + + Source Code: https://github.com/dbidwell94/stationeers_lang + ]]> + diff --git a/csharp_mod/Plugin.cs b/csharp_mod/Plugin.cs index 94d177b..fa576fe 100644 --- a/csharp_mod/Plugin.cs +++ b/csharp_mod/Plugin.cs @@ -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); diff --git a/csharp_mod/stationeersSlang.csproj b/csharp_mod/stationeersSlang.csproj index 0880395..a86c204 100644 --- a/csharp_mod/stationeersSlang.csproj +++ b/csharp_mod/stationeersSlang.csproj @@ -5,7 +5,7 @@ enable StationeersSlang Slang Compiler Bridge - 0.1.0 + 0.1.1 true latest diff --git a/rust_compiler/Cargo.lock b/rust_compiler/Cargo.lock index 664669d..5b620a0 100644 --- a/rust_compiler/Cargo.lock +++ b/rust_compiler/Cargo.lock @@ -843,7 +843,7 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "slang" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "clap", diff --git a/rust_compiler/Cargo.toml b/rust_compiler/Cargo.toml index ee900f1..6ac3e63 100644 --- a/rust_compiler/Cargo.toml +++ b/rust_compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "slang" -version = "0.1.0" +version = "0.1.1" edition = "2021" [workspace] diff --git a/rust_compiler/libs/parser/src/sys_call.rs b/rust_compiler/libs/parser/src/sys_call.rs index cb6e85b..c44ec95 100644 --- a/rust_compiler/libs/parser/src/sys_call.rs +++ b/rust_compiler/libs/parser/src/sys_call.rs @@ -9,97 +9,97 @@ documented! { /// ## IC10 /// `acos r? a(r?|num)` /// ## Slang - /// `(number|var).acos();` + /// `let item = acos(number|var|expression);` Acos(Box>), /// 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>), /// 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>), /// 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>, Box>), /// 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>), /// 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>), /// 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>), /// 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>), /// 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>), /// 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>, Box>), /// 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>, Box>), /// 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>), /// 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>), /// 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>), /// 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>), } } @@ -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, Spanned), /// 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, Spanned, @@ -180,26 +183,31 @@ documented! { /// `lb r? deviceHash logicType batchMode` /// ## Slang /// `loadBatched(deviceHash, "Variable", "LogicType");` + /// `lb(deviceHash, "Variable", "LogicType");` LoadBatch(Spanned, Spanned, Spanned), /// 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, Spanned, Box>), /// 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, Spanned, Box>), /// 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, Spanned,