Molten

Troubleshooting and FAQ

Building and running

molten-game says Gameplay build requires sources and an output library. The game folder has no .cast file and no C in native/. Add at least one Cast file (a component and a behavior).

initial build failed and could not start the gameplay module. The first build of your code failed; the errors are printed above. Run castc check DIR for the same list. Once a game is running, a failed build keeps the old code instead.

A window test or the game hangs at startup on WSL. WSLg's display server is stuck. Run wsl --shutdown and try again, or use SDL_VIDEO_DRIVER=wayland.

Linux machine without a display. Run with SDL_VIDEO_DRIVER=offscreen (works with Mesa's llvmpipe), or configure with -DMOLTEN_WINDOW_TESTS=OFF to skip the window tests.

castc run from Git Bash on Windows fails with include file 'limits.h' not found. Pass the compiler explicitly: castc run file.cast --cc /c/path/to/build/debug/bin/Debug/molten_tcc.exe. From PowerShell or cmd it works without --cc.

Devtools' Play does nothing / the game doesn't show up. Play needs a Debug build (the Release preset has no dev link). Check the Console tab; another program may be using port 7420 (molten-devtools --server 127.0.0.1:0 makes Play start its own dev server on a free port).

Space pauses my game

Space reaches gameplay in every build. In builds with dev link it also pauses the simulation after the press reaches a tick. Press it again to resume.

Escape quits my game

Set escape_quits = false in game.toml, handle Escape (key 41) yourself, and give players a Quit button that calls requestQuit().

Cast compile errors

Error Fix
cannot convert float to int Floats never convert to integers implicitly: int(x)
operator '==' does not accept int and float Convert one side: float(i) == x
nullable receiver must be narrowed before member access Check it first: if (!x) return;, or x?.member. Narrowing is lost across loops; check again inside or after the loop
type Object has no member 'coin' h.get() gives a plain Object. Use h.as<Coin>()?.get()
type Crate has no member 'rigidBody' The .object file doesn't list that component; add it there
a condition must be bool or a number, got Handle<Object> if (h.get()) instead of if (h)
'Transform' is not a component Import it: import { behavior, Transform } from "molten";
default export must call 'behavior' imported from 'molten' Import behavior from "molten"
behavior requires at least one component List at least one component
type <query object> has no member 'transform' Add the component to the behavior's list
duplicate generated C name for 'f' Two modules export a function with the same name; rename one
expected import, function, struct, const, or default behavior Module-level let, enum or another statement at the top level. Use const, a string union, or a component
expected ')' Default or optional parameters, or an arrow with a result type. None are supported
exponentiation operators are not supported yet pow(x, y)
unknown name 'Math' / 'console' Use sin, min, ... directly and print(...)
'switchScreen' requires 1 arguments switchScreen takes only the screen name; the screen's file picks the level
cannot convert int to Key (on keyDown(26)) Use a named key such as keyDown("W"). See Engine API.
type Camera has no member 'fov_y_degrees' Use fovYDegrees, nearPlane and farPlane
component fields of type uint8 have no M6 schema field type Use int or uint32 in components
arena-backed and fixed array component fields require @transient Strings, arrays, maps and classes in components must be @transient (not saved)
frame allocation escapes into component storage / game storage Allocate in a longer-lived arena: new(level) / new(game)
cannot assign to captured variable 'x' Arrow captures are snapshots; keep mutable state in an object or component
switch is not exhaustive Handle every member or add default
'new' requires a class name Structs are constructed by calling them: Item(2)
inheritance is not supported Use an interface with implements

Things that compile but don't do what you meant

Writing through a copied component does nothing. const game = obj.coinGame; game.score += 1; changes a copy. Write obj.coinGame.score += 1.

A behavior keeps running on the pause or menu screen. Behaviors run every tick regardless of the screen. Check screenIs("Playing").

A HUD text shows a number instead of the text. You published the same binding name with uiSetText and uiSetNumber. Use two names.

Changing a component default in Cast didn't change my objects. Existing objects keep their values across code reloads; only new objects get new defaults. Set per-type values in the .object file, or restart the level.

My .object edit didn't reach some objects. Those objects' fields were changed at runtime (by gameplay, devtools, or a changed default), and runtime changes win. See Live reload.

spawnObject returns a null handle. The type name is a string and is only checked at runtime: check the spelling (PascalCase of the file name).

Objects I spawned disappeared. Objects spawned while a level is loaded belong to it and are destroyed when it unloads (switchScreen reloads the level every time).

Concept file diagnostics

castc check and the editor validate built-in and Cast component values and asset paths. The running game also validates schemas registered by native gameplay code.

Message Cause
unknown component 'coinn' (no component named Coinn is registered) A misspelled component key
component Coin has no field 'colour' (fields: value, spinSpeed, angle) A misspelled field
RigidBody.motion must be an integer in range A value of the wrong type or out of its allowed range
CoinGame.goal = 500 is outside @range(1, 50) A warning: the value is still used
asset not found: ...models/nope.gltf A wrong asset path

Watch the console when you first run a game after editing concept files.

FAQ

Can I write gameplay in C or C++? Yes. Put C in native/. A game with Cast compiles everything with TinyCC in development, so native/ code must be C that TinyCC accepts. A C-only game uses MSVC or gcc/clang. See samples/farmhouse/native/farmhouse.c and defer and calling C.

Is there a macOS, web, console or mobile version? Not planned for now.

Can players get live updates? No. Live reload is a development feature only.

Does Molten have coroutines / await? Not yet; the keywords are reserved.

How do I find all objects of a type? Write a behavior over a component that type has, or keep handles in a list (see Gridline's grid_objects.cast).

Which GPU does it use? How do I pick another? By default the first compatible discrete GPU, otherwise the first compatible adapter. Startup logs the choice (renderer: selected Vulkan adapter 0: ...) and any adapter it skipped, with the reason. Set the MOLTEN_GPU environment variable to force one, in dev and shipped builds:

MOLTEN_GPU Picks
1 The adapter with that zero-based index
discrete / integrated The first compatible adapter of that type
any other text The first compatible adapter whose name contains it (case-insensitive), e.g. nvidia

If nothing matches, the game stops with MOLTEN_GPU='...': no matching Vulkan adapter.

View this page's source on GitHub