# s2s2lua
**Transpile Stranded II `.s2s` scripts to Lua for [OpenStranded](https://github.com/OpenStranded/s2mod-tool).**
## Overview
`s2s2lua` is a Rust library and CLI tool that parses `.s2s` script files from
the game Stranded II and generates equivalent Lua code compatible with the
OpenStranded engine. All s2s built-in commands are translated to calls in the
`core_api.*` namespace.
[Documentation](https://docs.rs/s2s2lua) |
[Crate](https://crates.io/crates/s2s2lua)
## Usage
### CLI
```bash
# Single file
s2s2lua script.s2s output_dir/
# Multiple files or directories
s2s2lua script1.s2s script2.s2s maps/ output_dir/
# Custom namespace
s2s2lua -n myapi script.s2s output_dir/
```
Options:
| `-n`, `--namespace` | Namespace prefix for emitted commands (default: `core_api`) |
### Library
```toml
[dependencies]
s2s2lua = "0.1"
```
```rust
use s2s2lua::{S2sParser, LuaGenerator, GenOptions};
let script = S2sParser::parse(r#"on:start { msg "Hello!"; }"#).unwrap();
let lua = LuaGenerator::generate(&script, GenOptions::default()).unwrap();
println!("{}", lua);
```
## Project Structure
| `src/ast.rs` | AST node types |
| `src/token.rs` | Logos-based lexer / tokenizer |
| `src/parser/` | Recursive-descent `.s2s` parser |
| `src/generator/` | Lua code generator |
| `src/error.rs` | Error types |
| `src/main.rs` | CLI entry point |
| `tests/in/` | Test input `.s2s` scripts |
## Test Input Files
The files in `tests/in/` are original Stranded II scripts. They are the
property of **Unreal Software** (https://www.strandedonline.de/s2_info.php)
and are included for testing purposes only.
## License
GNU General Public License v3.0 or later — see [LICENSE](LICENSE) and [NOTICE](NOTICE).