Stationeers

Stationeers

评价数不足
Slang
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
2.655 MB
12 月 7 日 下午 7:03
12 月 9 日 下午 11:18
7 项改动说明 ( 查看 )

订阅以下载
Slang

描述
Slang: High-Level Programming for Stationeers

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 IC10 instantly.

NOTE: This project is in BETA. Expect updates and changes!

Features
  • In-Game Compilation: No external tools needed. Write Slang directly in the IC editor.
  • No More Register Juggling: Define variables with let (e.g., let temp = 300). The compiler manages r0-r15 for you.
  • Control Flow: Write readable logic with if, else, while, loop, break, and continue.
  • Functions: Create reusable code blocks with arguments.
  • Smart Editor: Get real-time syntax highlighting and error checking (red text) as you type.
  • Persistent Source: Your high-level Slang code is saved to the chip, so it's there when you come back.
  • Optimizations: Features like Constant Folding calculate math at compile time to save instructions.
  • Device Aliasing: Simple mapping: device sensor = "d0".
  • Temperature Literals: 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)

Installation
This is a StationeersLaunchPad Plugin Mod.
1. Install BepInEx (required).
2. Install StationeersLaunchPad.
3. Subscribe to Slang.

Usage
1. Open any IC10 housing or editor in-game.
2. Write your Slang code.
3. Press Confirm. The mod compiles your code to IC10 and loads it onto the chip.

Example 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; }

Known Issues (Beta)
  • Code Size: Compiled output is currently more verbose than hand-optimized assembly. Optimization passes are planned.
  • Stack Access: Direct stack memory access is disabled to prevent conflicts with the compiler's internal memory management.
  • Documentation: In-game tooltips for syscalls (like load, set) are WIP. Check the "Slang" entry in the Stationpedia (F1) for help.
  • Debugging: Runtime errors currently point to the compiled IC10 line number, not your Slang source line. Source mapping is coming soon.

Planned Features
  • 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.

FAQ
Q: What is the DLL extracted to my temp folder?
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.

Q: Is this compatible with my current save?
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.

Useful Links
Source Code on GitHub[github.com]
Stationeers Official Discord[discord.gg]
Stationeers Modding Discord[discord.gg]
4 条留言
JoeDiertay  [作者] 13 小时以前 
I could probably also work on some "context awareness" in the compiler to see if you are trying to pass a string into a batched function and automatically hash it for you
JoeDiertay  [作者] 14 小时以前 
As for functions, I'm working on doing a code refactor of the tokenizer right now. When that's done and I get the rest of the IC10 built-in functions in, I'll work on fixing up the ABI for functions :)
JoeDiertay  [作者] 14 小时以前 
Thanks for trying Slang!

So IC10 really doesn't have a concept of "Strings". So in Slang if you want to use a string you generally are going to want to use the `hash("SomeString")` function. As of _now_ LogicTypes and other things _are_ handled as strings in Slang.

Such as:

[code]
const solarPanels = hash("StructureSolarPanelDual");

lbn(solarPanels, "Charge", "Sum");
[/code]

In the future I will be strongly typing the structure names, logic types, and batch modes so that autocomplete works as intended and misuse will cause compiler errors in game :)
reality 12 月 8 日 下午 11:57 
hey, congrats on the beta release! i really really love using this. it's reduced the friction and slimmed the difficulty curve of getting into stationeers coding for me quite significantly. the same tasks that I was shooting for took less than half the time because of how approachable this is.

i think you mention it somewhere in the stationpedia where functions don't quite work as intended and i'm noticing that as well (various issues with scope-awareness and variable usage). i'm really excited for when this fully implemented!

i also couldn't figure out if there was a way to set strings or really use strings at all yet? looking forward to the feature parity for IC10.

thanks so much for making this and i hope you continue to work on it! :steamthumbsup: