Open-Source Project

WarScript - embeddable scripting language

WarScript

Flexible, extensible, and production-tested - ready for your game.

What is WarScript?

A Scripting Language Built for Games

WarScript is a custom scripting language with an interpreter written in C#. It's designed specifically for embedding in games, giving players and modders a clean, approachable language to script game behavior at runtime - no recompilation needed.

The key difference: WarScript isn't trying to be C#. It's its own language with a simple, readable syntax. But because the interpreter is written in C#, it features native bindings in both directions - call C# code from your scripts, and invoke scripts from your C# game code.

Born out of Warman's development and battle-tested in a production game environment, WarScript handles everything from event hooks and gameplay logic to spawning units and applying modifiers.

sandbox-init.ws
# Native event. Called each time a player enters.
# The 'player' param is a native reference
fun on_player_enter_room[player]
    print "on_player_enter_room: " + player

    Unit_apply_modifier[player, "Modifier_NewHero"]
end

# Native event. Called when a unit dies.
fun on_unit_died[unit]
    position = Unit_get_position[unit]
    print "on_unit_died: " + unit + " at: " + position

    soul = spawn_soul[position]
    print soul
end
game-logic.ws
# Variables and timing
secondsForClock = 1
destroyAfterXCycles = 10
t = 0
c = 0

# Called each simulation tick
fun tick[dt]
    t = t + 1 * dt

    if t > secondsForClock
        t = 0
        c = c + 1
        clock[]
    end
end

fun clock[]
    print "clock: " + c

    if (c >= destroyAfterXCycles)
        players = get_players[]
        loop player in players
            Player_give_exp[player, 1]
            Unit_apply_modifier[player, "Modifier_CollectedSouls"]
            unit = spawn_unit["EnemyPreset_Bee", Unit_get_position[player], 1, false, false, false]
        end
        detach[]
    end
end

The Language

Clean Syntax, Native Power

WarScript uses its own syntax - fun/end blocks, square-bracket function calls, loop/in iteration, and # comments. It's deliberately simple so that modders can pick it up quickly without needing programming experience.

But underneath that simplicity sits serious power. Native bindings let scripts call directly into your C# game code - spawning units, applying modifiers, reading positions, granting experience. Your game's API becomes the scripting API, with no translation layer in between.

The binding works both ways: your C# code can invoke script functions, pass native references into scripts, and receive results back. Scripts and game code communicate seamlessly.

Why WarScript?

Built for Game Developers

Native C# Bindings

Call C# code from scripts and invoke scripts from C#. Native references pass between both worlds, so scripts can manipulate real game objects directly.

Fully Extensible Parser

The interpreter's C# source is designed for modification. Add new keywords, define custom operators, or change the syntax entirely. The whole parser is yours to shape.

Production-Tested

This isn't a toy project. WarScript powers the scripting layer in Warman, a shipped game with real players. The API reference is from a live, working system.

Open-Source

The interpreter, the tooling, and the extensions are all open-source. Inspect the code, contribute improvements, and have confidence the project won't disappear behind a paywall.

VSCode Extension

A dedicated VS Code extension provides syntax highlighting and autocomplete - including support for your own native bindings. The extension is open-source too, so you can modify it if you change the language syntax.

Auto-Generated Docs

Utilities are included to generate API documentation from your own native bindings. If you embed WarScript in your game, you get your own reference docs - just like the Warman API reference.

Integration

Embed in Your Game, Expose Your API

Integration follows a straightforward pattern: embed the interpreter, register the C# types and functions you want to expose as native bindings, and let scripts call them. Functions like spawn_unit, Unit_apply_modifier, and Player_give_exp in the samples above are all native bindings - C# methods that scripts call directly.

Event hooks like on_attach, tick, on_player_enter_room, and on_unit_died are defined in scripts and called by your game code when the corresponding events fire. It's a clean, two-way integration.

When you're ready to ship, the included documentation generator inspects your native bindings and produces a complete API reference - the same tooling that generated the Warman API docs you can browse right now.

C# Interpreter

Full source available. Extend keywords, operators, and syntax to fit your game's needs.

Doc Generator

Auto-generate API reference documentation from your native bindings. Ship docs alongside your game.

VS Code Extension

Syntax highlighting and autocomplete for WarScript files, including your custom native bindings. Open-source and modifiable.

Native Bindings

Bidirectional - call C# from scripts and scripts from C#. Native references pass seamlessly between both worlds.

Proof in Production

See It in Action

Warman serves as the reference implementation for WarScript. Every scriptable game mechanic - combat events, unit spawning, modifier application, experience rewards - runs through WarScript. The API documentation is generated directly from Warman's native bindings, showing exactly how a production game exposes its systems to scripting.

When you adopt WarScript, you're using the same technology that's already handling real gameplay logic in a live game. And because the whole interpreter source is available, you can study exactly how Warman integrates it and adapt the approach for your own project.

Support the Project

Help WarScript Grow

WarScript is free and open-source. If you find it useful and want to support continued development, consider becoming a patron. Your support helps fund new features, documentation, and community tooling.

But most importantly - just use it. Try WarScript in your game, report issues, suggest features, and help build the community. Adoption and feedback are the most valuable contributions of all.

Get Started

Explore the API, read the docs, and start scripting.