GameScript is a lightweight, indentation-based scripting language and toolchain built for game development. It compiles to a compact bytecode format executed by a small embeddable VM, and ships with a full Language Server for first-class editor support.
GameScript has three scalar types (bool, int, string), four method kinds, and a prefix-based identifier system that makes every symbol's role visible at a glance:
// constants (.const)
int ^npc_knight = 2
// context variables (.context) — backed by a host-provided slot
bool %logged_in = 0
// methods (.gs)
command print(string $value) // host-implemented opcode, no body
func greet(string $name) // regular function, returns to caller
string $msg = "Hello, " + $name
print($msg)
label do_login() // one-way jump (GOTO), never returns
~greet("adventurer")
mn_button_1 login:submit() // trigger — UI event entry point
@do_login()
| Kind | Prefix | Returns? | Notes |
|---|---|---|---|
func |
~ |
✅ | Standard function; returns to caller |
label |
@ |
❌ | One-way jump; never returns |
command |
— | ✅ | Declares a host opcode; no body allowed |
trigger |
— | ❌ | Event entry point; cannot be called from script |
| Symbol | Prefix | Declared in |
|---|---|---|
| Local var | $ |
.gs |
| Constant | ^ |
.const |
| Context var | % |
.context |
Learn more:
- LANGUAGE.md — full language reference: types, operators, control flow, triggers, and common patterns
- EMBEDDING.md — hosting GameScript in your C# game: compiling, running, suspending, and debugging scripts
| Folder | Purpose |
|---|---|
GameScript.Language/ |
Lexer, parser, AST, visitors (index, semantic, type), bytecode compiler |
GameScript.Bytecode/ |
Bytecode VM and runtime (ScriptState, ScriptRunner) |
GameScript.DebugAdapter/ |
DAP debug server — embed in your game to debug scripts from VS Code |
GameScript.LanguageServer/ |
LSP server executable |
GameScript.Vscode/ |
VS Code extension |
GameScript.VisualStudio/ |
Visual Studio 2022 extension |
| Package | Purpose |
|---|---|
GameScript.Bytecode |
Embed the VM — register opcode handlers, create ScriptState, run bytecode. |
GameScript.Language |
Full toolchain — parse source, build the symbol index, run analysis passes, compile to bytecode. |
GameScript.DebugAdapter |
In-process DAP server — attach VS Code to a running game and debug live scripts. |
The VS Code extension (GameScript.Vscode) bundles the language server and provides:
- Semantic syntax highlighting for
.gs,.const, and.contextfiles - Completions, hover tooltips, and real-time diagnostics
- Go to Definition, Find All References, Document Highlights
- Rename Symbol, Document Symbols, Workspace Symbols
- Script debugging — attach to a running game, set breakpoints, step, and inspect variables (see EMBEDDING.md)
- Syntax highlighting and constant completion for Object Definition files (
.varp,.varn,.item,.npc,.menu,.obj,.tile,.inv,.anim,.param,.tex,.rig)
A Visual Studio 2022 extension (GameScript.VisualStudio) is also available.
git clone https://github.com/Juiix/GameScript.git
cd GameScript
dotnet buildPull requests are welcome. Please open an issue first to discuss major changes. See CONTRIBUTING.md for coding standards and branch workflow.
GameScript is licensed under the Apache License 2.0 — see LICENSE for details.