<?xml version="1.0" encoding="utf-8"?>
<ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Name>Slang</Name>
  <Author>JoeDiertay</Author>
  <Version>0.2.1</Version>
  <Description>
[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 IC10 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.

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

        <color=#ffa500><b>Features</b></color>
        - <b>In-Game Compilation:</b> Write high-level logic directly in the chip editor.
        - <b>Automatic Registers:</b> Stop juggling <color=#add8e6>r0-r15</color>. Just use <color=#569cd6>let</color> variables.
        - <b>Control Flow:</b> Full support for <color=#c586c0>if</color>, <color=#c586c0>else</color>, <color=#c586c0>while</color>, and <color=#c586c0>loop</color>.
        - <b>Smart Editor:</b> Integrated syntax highlighting and real-time error checking.
        - <b>Persistent Code:</b> Your Slang source code is saved with the chip, so you never lose your work.
        - <b>Optimization:</b> The compiler automatically optimizes constant math (e.g., <color=#b5cea8>1 + 2</color> becomes <color=#b5cea8>3</color>).

        <color=#ffa500><b>Example Code</b></color>
        <color=#569cd6>device</color> sensor = <color=#ce9178>"d0"</color>;
        <color=#569cd6>const</color> MAX_TEMP = <color=#b5cea8>300k</color>;

        <color=#c586c0>loop</color> {
        <color=#569cd6>let</color> temp = sensor.Temperature;
        <color=#c586c0>if</color> (temp > MAX_TEMP) {
        <color=#6a9955>// Do logic here</color>
        }
        yield();
        }

        <b><color=#ffff00>Installation</color></b>
        This is a <color=#ffa500>StationeersLaunchPad</color> Plugin Mod. It requires BepInEx to be installed.
        See: https://github.com/StationeersLaunchPad/StationeersLaunchPad

        Source Code: https://github.com/dbidwell94/stationeers_lang
        ]]></InGameDescription>
</ModMetadata>
