Molten

Command-line tools

All tools are built into build/<preset>/bin/<Config>/ (Windows) or build/<preset>/bin/ (Linux).

castc

castc fmt [--check] FILE...
castc check DIR
castc build GAME_DIR OUT_DIR [--dev|--release] [--no-entry]
castc run FILE.cast [--cc PATH]
castc test [DIR] [--cc PATH]
castc --help | --version
Command Does
check DIR Checks a game folder: Cast code, game.toml, object/level/chunk/screen files, UI and styles. Prints N objects, N screens, N levels or file:line:col: error: message lines and exits 1
fmt FILE... Formats concept, UI and style files in place. --check only lists files that would change and exits 1 (2 on a syntax error). Does not format .cast code or game.toml
build GAME_DIR OUT_DIR Emits the C for a game (castc-output.md). --dev adds dev checks, --release omits them, --no-entry leaves out the module entry for games whose native/ defines it
run FILE.cast Compiles and runs a standalone program with export function main(): void
test [DIR] Runs the language test suite (tests/): compile, error and run cases

run and test use molten_tcc next to castc, else $CC, else cl.exe / cc. From Git Bash on Windows, pass --cc with the full path to molten_tcc.exe if run fails with include file 'limits.h' not found.

molten-game

molten-game [--game DIR | --module FILE] [options]
Option Meaning
--game DIR Run the game in DIR with live reload
--module FILE Run a prebuilt gameplay library (no rebuilds)
--work-dir DIR Where builds, imports and shadow copies go (default <exe dir>/molten-work)
--start-level L Start on the screen that loads level L (else first_screen with L loaded)
--frames N Quit after N rendered frames
--sim-hz N Simulation ticks per second (default 60)
--screenshot FILE Save the last frame as a PNG on exit
--hidden Create the window hidden
--log-input Log every key, mouse button and wheel event
--no-gpu-debug Don't request GPU validation layers
--dev-server HOST:PORT / --no-dev-link Dev link address (default 127.0.0.1:7420) / turn it off
--dump-schemas FILE Build and load the module, write all component schemas as JSON, exit (no window)
--dump-world FILE On exit, write the level's placed objects (id, type, Transform) as JSON
--test-click ID Tests: click the UI widget with that id on the first frame (implies --fixed-step)
--input FILE Tests: play a scripted input file (below). Implies --fixed-step
--fixed-step Advance exactly one simulation tick per rendered frame instead of following the clock, so --frames N always simulates N ticks (N / 60 seconds at the default rate)
--quality low|medium|high M17: the graphics quality preset (overrides the player's settings.ini). low is the M16 look
--graphics standard|cinematic M17: lower the graphics tier (overrides settings.ini)
--window-size WxH M20: the window's size in pixels, e.g. 1920x1080 (frame-time measurements). On exit the game logs the last GPU frame time and its passes

In dev-link builds Space toggles simulation pause. Escape quits unless escape_quits = false.

Exit status

Status Meaning
0 The run finished and nothing is broken
1 Startup or runtime failure: initial gameplay build failed, renderer, a bad --input script, a screenshot that could not be saved
2 Bad command-line arguments
3 The run finished, but at exit an asset's latest load or import had failed (for example a shader compile error, a missing file passed to loadAsset), or the latest gameplay rebuild had failed and the old code was still running. The log lists them as ERROR: molten-game: exiting with N failed asset(s): .... The screen showed a fallback, so treat 3 as a failure

Input scripts

--input FILE drives a hidden run like a player would. Each line is a rendered frame number (from 0) and an action. The engine injects the action as real keyboard or mouse events at the start of that frame, so gameplay, UI and --log-input see it exactly as live input. Each frame runs one simulation tick, so the same script always gives the same run. # starts a comment.

# frame action
10 key down W              # Key names are the Cast Key names: W, Space, Left, LeftShift ...
70 key up W
75 key tap E               # down on frame 75, up on frame 76
20 mouse move 40 -5        # relative motion in window points: mouseDelta() sees (40, -5)
30 mouse down Left         # MouseButton names: Left, Right, Middle, X1, X2
31 mouse up Left
40 mouse click Right       # down this frame, up the next
45 mouse at 640 360        # move the pointer to a window position (for pointerPlane)
50 wheel 1                 # wheel notches, + = away from the user
60 click play              # click the UI widget with id "play" (frame 1 or later)
90 screenshot shots/a.png  # save this frame as a PNG (relative to the working directory)

Several actions can share a frame; motion on one frame is summed. Events from frame N reach the tick that runs during frame N. A screen's update starts counting on frame 1, because the first screen is entered during frame 0. An unknown key, button or action stops the run with FILE:LINE: message and status 1. A click on a widget that is not on screen also stops the run with status 1.

MOLTEN_HIDDEN_WINDOWS=1 SDL_AUDIO_DRIVER=dummy molten-game --game my-game --hidden \
    --no-dev-link --start-level arena --input walk.txt --frames 300 --screenshot end.png

Environment variables:

Variable Effect
MOLTEN_GPU Force a Vulkan adapter: a zero-based index, discrete, integrated, or part of the adapter name (also in shipped games)
MOLTEN_HIDDEN_WINDOWS=1 Create windows hidden (the tests use it on Windows)
SDL_VIDEO_DRIVER=offscreen No window at all (Linux tests, headless machines)
SDL_AUDIO_DRIVER=dummy Silence audio

molten-devtools

molten-devtools [--game DIR] [--level NAME] [--server HOST:PORT] [--work-dir DIR]
                [--size WxH] [--scale S] [--no-gpu-debug]

With --game it opens the folder in Edit mode; without it, it attaches to games connected to the dev server. --server with port 0 makes Play start its own molten-dev on a free port. Other flags (--play, --select, --set, --save, --stop, --dock-tab, --frames, --screenshot, --script) automate it for tests.

dev-run

dev-run [game folder] [-NoBuild]          # Windows (dev-run.cmd / dev-run.ps1)
./dev-run.sh [game folder] [--no-build]   # Linux

Builds molten-dev, molten-game and molten-devtools (Debug) and opens the folder (default samples/farmhouse) in devtools.

molten-dev

molten-dev [--bind ADDR] [--port N]

The dev server (default 127.0.0.1:7420). Devtools' Play starts it when needed.

molten-import

molten-import <source file> <source root> <output root> [--include dir]

Imports one asset into its runtime format. The engine runs it for you.

molten

molten build --release GAME_DIR OUT_DIR [--clang PATH] [--steam]

Builds a standalone game folder. See Shipping.

molten-bake (M18)

molten-bake <game folder> <level> [--work-dir DIR] [--threads N] [--samples N] [--quiet] bakes a level's bounced light into assets/lighting/<level>/ and levels/<level>/lighting.bake. It prints progress N lines and exits 0 on success. See Built-in components.

View this page's source on GitHub