Modding
Steam Alchemy mods are JSON files. A mod defines elements, their appearance, variables, reactions, events, and functions.
The mod format is in alpha and may change. The examples below use the current format.
Basic mod structure
The basic mod structure looks like this:
{
"settings": {},
"elements": {},
"reactions": [],
"classes": {},
"events": {},
"functions": {}
}settings — optional (default: {}). General mod settings.elements — optional (default: {}). Element definitions, indexed by element ID.reactions — optional (default: []). Recipes and their result operations.classes — optional (default: {}). Shared appearance settings.events — optional (default: {}). Global event operation lists.functions — optional (default: {}). Reusable operation lists with arguments.
Use valid JSON with double-quoted property names and string values. Most examples on this page show one section or operation. See the working examples for complete mods.
Settings
Settings example:
{
"settings": {
"is_cloneable": false,
"is_initial_spawning_enabled": true,
"is_void_button_visible": true,
"void_filter": ["Water"]
}
}is_cloneable — optional (default: true). Enables double-click cloning.is_initial_spawning_enabled — optional (default: true). Allows double-clicking an empty area of the board to run events.on_start at that position.is_void_button_visible — optional (default: false). Displays the Void button in the top menu.void_filter — optional (default: []). Limits which element IDs the Void button can remove. An empty array allows all elements.
The Void button removes selected elements, or all eligible elements when nothing is selected.
Values
There are three value formats: static values, bindings, and computed values.
Static values
Use ordinary JSON values directly:
{
"number": 10,
"string": "Hello",
"boolean": true,
"array": ["Stone", "Coal"],
"dictionary": {"amount": 10},
"empty": null
}bind
Reads a variable and subscribes to its changes:
{"type": "bind", "target": {"id": "Counter", "name": "count", "precision": 0}}target.name — required. Property name.target.id — optional. Without it, uses the current element type.target.precision — optional (default: 1 for displayed floating-point values). The number of decimal places shown in text. The stored value keeps its original precision.
A property's scope determines whether the binding reads the shared global value or the current instance's local value. Local bindings are restricted to their own instance.
computed
Evaluates an expression every time the value is requested:
{"type": "computed", "expression": "g('Counter', 'count') * 2"}See Expression helpers for available functions.
Elements
Element example:
{
"elements": {
"Player": {
"display": [
{"type": "icon", "name": "user"},
" Player [",
{"type": "bind", "target": {"name": "health", "precision": 0}},
"]"
],
"description": "A player with independent health.",
"custom_props": {
"health": {"scope": "local", "type": "number", "value": 100},
"status": {"type": "string", "value": "Idle"},
"is_enabled": {"type": "boolean", "value": true}
},
"class": ["earth", "demo"],
"is_static": true,
"is_cloneable": false
}
}
}Player — the element ID. A string that identifies an element type. Each physical instance has its own UUID.display — optional (default: element ID). Defines the content shown inside each instance on the board. Use a string for a text label or an array to combine text, values, icons, and progress bars.description — optional. The tooltip shown when hovering over an instance. Accepts a string or an array of display items.custom_props — optional (default: {}). The element's variables.class — optional. A class name or an array of class names. For multiple classes, use ["earth", "demo"].is_static — optional (default: false). When true, the element stays on the board after a reaction. It moves toward the reaction center with the other reagents.is_cloneable — optional (default: settings.is_cloneable). Allows double-click the element to clone it.events — optional (default: {}). Element event definitions.
The demo class in this example must be defined in classes. Built-in classes, such as earth, are available directly.
Display items
Text, icons, and resolved values are joined in array order. Include spaces and line breaks in your strings to control the text layout. Each progress bar occupies a separate row. Content after a progress bar starts on the next row.
The Player example above shows a user icon followed by Player [100]. Its bind reads the current instance's health and updates the text when that value changes.
{
"display": [
{"type": "icon", "name": "lightbulb", "size": 20},
" Light Bulb [",
{"type": "bind", "target": {"name": "charge", "precision": 0}},
"]",
{
"type": "progress",
"value": {"type": "bind", "target": {"name": "charge"}},
"min": 0,
"max": 100,
"width": 160,
"height": 8
}
]
}Strings support BBCode, for example [b]Bold text[/b].
See the Godot BBCode documentation for the full usage reference.icon.name — an icon name from the game's icon library, without .svg.icon.size — optional. Icon size in pixels. The default depends on whether it is used in element text or a description.icon.color — optional. Overrides the class's icon_color.progress.value — the progress value. Supports a static value, bind, or computed.progress.min / progress.max — optional. Support the same value formats. If omitted for a bound variable, its min / max property event values are used. The fallback range is 0–100.progress.width / progress.height — optional. Override the UI template's dimensions.progress.color — optional. Overrides the fill color.
Custom properties
{
"custom_props": {
"count": {"type": "number", "value": 0},
"durability": {"scope": "local", "type": "number", "value": 100},
"status": {"type": "string", "value": "Ready"},
"is_enabled": {"type": "boolean", "value": true},
"saved": {"type": "array", "value": []},
"data": {"type": "dictionary", "value": {}},
"optional_value": {"type": "any", "value": null}
}
}type — required. number, string, boolean, array, dictionary, or any.value — the initial value. Must match type.scope — optional (default: "global"). "global" shares a value between all instances of the type. "local" stores an independent value on each physical instance.events — optional (default: {}). Property event definitions.
any accepts JSON-compatible values, including null.
Use g('Element', 'name') to access a global property in expression and l(uuid, 'name') to access a local property. A missing property returns null. Check existence with an expression such as g(el_id(), 'cost') != null.
Local values are saved and synchronized with the instance. A clone receives an independent copy of them.
Property events
{
"charge": {
"scope": "local",
"type": "number",
"value": 100,
"events": {
"min": {"value": 0},
"max": {"value": 100},
"at": {
"value": 0,
"is_enabled": true,
"do": [
{
"type": "set_class",
"target": {"uuid": {"type": "computed", "expression": "el_uuid()"}},
"class": "unlit"
}
]
}
}
}
}min / max — numeric limits. Values outside the allowed range are clamped.at — runs its operations when the assigned value equals value. Numeric equality is approximate.value — required. The threshold, with the same type as the property.do — optional (default: []). An operation array or a reaction object.is_enabled — optional (default: true). Enables event operations. Shared by type and property.is_included — optional for limits (default: true). Controls when limit operations run. With true, they run when an assigned value exceeds the limit. With false, equality also triggers them.
Use at to run operations when a value reaches an exact threshold, such as zero.
Local property event operations keep the changed instance's context, so el_uuid() refers to that instance.
Reactions
Reaction example:
{
"reagents": ["ElementA", "ElementB"],
"spawn_angle": 0,
"spawn_force": 1.5,
"result": ["ElementC"]
}reagents — required. The elements participating in the reaction. Repeated IDs require separate instances.result — the operation list, executed in order. A string such as "ElementC" is a shorthand for spawning one element.spawn_style — optional (default: "short"). Controls the result spawn animation. "long" is also supported.spawn_angle — optional. Starting angle in degrees. If omitted, the server chooses a random angle. 0 starts to the right, 90 starts downward. Multiple results are evenly spaced around the spawn ellipse from this angle.spawn_force — optional (default: 1). A non-negative multiplier for the result spread distance. 0 disables outward movement.
Non-static reagents are consumed after the result operations run. Static reagents remain on the board.
A drop reaction requires the visual rectangles to overlap by at least 40% of the smaller element's area. Selection can trigger a reaction between elements at any distance.
Operation types
Operations are used in reaction result, function result, and event do lists. Referenced elements, classes, and functions must exist in the mod. Property declarations define their types, scopes, and events.
set
Assigns a value to a variable:
{
"type": "set",
"target": {"id": "Counter", "name": "count"},
"value": {"type": "computed", "expression": "g('Counter', 'count') + 1"}
}target.name — the property name.value — the new value. For a declared property, its type must match the property's type.
Use strings and booleans directly:
[
{"type": "set", "target": {"id": "Player", "name": "status"}, "value": "Ready"},
{"type": "set", "target": {"id": "Player", "name": "is_enabled"}, "value": true}
]A global property can be addressed by id and name even without an instance on the board. For a local property, target selects physical instances. A grouped set changes each local value separately. It writes a global property once per element type within that operation.
If a property is missing from custom_props, set creates it as a global variable of type any. Its first assignment prints a console warning. The variable supports bindings, synchronization, and saving. Declare local properties, type constraints, and property events in custom_props. An incompatible value for a declared property skips the assignment and prints a console message.
if
Runs one of two branches:
{
"type": "if",
"condition": "g('Counter', 'count') >= 10",
"then": ["Reward"],
"else": []
}condition — a string expression, a computed value, or a boolean. A string condition is evaluated as an expression.then — operations to run when the condition is true.else — optional (default: []). Operations to run when the condition is false.
spawn
Spawns elements:
{
"type": "spawn",
"element": "Stone",
"quantity": 3
}element — an element ID, an array of IDs, or a computed value that returns either.quantity — optional (default: 1). The number to spawn for each ID. Can be computed.
remove
Removes all idle elements of one type from the board:
{
"type": "remove",
"target": {"id": "Stone", "limit": -1}
}target.id — the element type to remove.target.limit — optional (default: 1). The maximum number of instances to remove. Use -1 for all matches.
To remove up to three Stone instances:
{
"type": "remove",
"target": {"id": "Stone", "limit": 3}
}set_class
Changes the selected instances' visual class with an animated color transition:
{
"type": "set_class",
"target": {"from": "reagents", "id": "Bulb", "limit": -1},
"class": "lit"
}class — a class name, an array of class names, or a computed value. Use null to restore the element's original class.
The element keeps its ID, UUID, and stored variable values when its class changes.
set_event_enabled
Enables or disables an event:
{
"type": "set_event_enabled",
"target": {"id": "Bulb"},
"event": "on_tick",
"is_enabled": false
}For a property event, include its property name:
{
"type": "set_event_enabled",
"target": {"id": "Bulb", "name": "charge"},
"event": "at",
"is_enabled": false
}is_enabled is shared by the whole element type. Disabling a property's min or max event stops its operations. The numeric limit remains active.
call
Calls a defined function once in the current context:
{
"type": "call",
"function": "recharge",
"args": {"amount": 10}
}function — the function name.args — optional (default: {}). Argument values. Defined arguments must be provided.
The function inherits the current instance context. See Targeted function calls to call a function for selected instances.
run_reaction
Runs another operation list or reaction object in the current context:
{
"type": "run_reaction",
"target": {"from": "tools", "limit": -1},
"reaction": [
{
"type": "set",
"target": {"uuid": {"type": "computed", "expression": "el_uuid()"}, "name": "durability"},
"value": 100
}
]
}reaction — an operation array, or a computed value returning an array.target — optional. Like call.target, runs the list separately for each selected instance.
stop
{"type": "stop"}Stops the remaining operations and cancels automatic reagent consumption and movement. Operations already performed remain in effect.
Inside a function or a targeted loop, stop stops the whole reaction/event context, including later instances. Use if to run actions conditionally for one instance.
Targets and selectors
Each physical element on the board has a UUID. Instances of the same type share an element ID, such as Stone Pickaxe. Each instance has its own UUID, which is preserved when saving the board. Clones receive new UUIDs.
el_uuid() returns the current instance's UUID. el_id() returns its element type ID.
Selectors
A selector chooses physical instances. This example selects every available Stone Pickaxe with durability above zero:
{
"id": "Stone Pickaxe",
"filter": "l(el_uuid(), 'durability') > 0",
"limit": -1
}id — optional. Limits the selection to an element type.filter — a boolean expression evaluated for each candidate instance. Required if there is no id, from, or uuid.limit — optional (default: 1). Maximum number of instances. -1 selects all matches. 0 selects none.uuid — optional. Selects one exact physical instance. Accepts a string or a computed value.
While the filter runs, el_uuid() and el_id() refer to the candidate being checked. l(el_uuid(), 'durability') reads that candidate's local durability.
By default, selectors search the board. uuid narrows the source to one instance. from uses a saved group, described under Aliases.
Using selectors in operations
Place a selector in an operation's target. This removes all available Stone instances from the board:
{
"type": "remove",
"target": {"id": "Stone", "limit": -1}
}The same selector format works in set, remove, set_class, set_event_enabled, call, and run_reaction. set and property event operations also include target.name to identify the property.
For a function call, put the selector in call.target. The function runs separately for every matching instance.
Targeted function calls
This example calls recharge for each available Bulb on the board:
{
"type": "call",
"function": "recharge",
"target": {"id": "Bulb", "limit": -1},
"args": {"amount": 10}
}Computed arguments are evaluated separately for each instance. Inside the function, el_uuid() and el_id() refer to that instance. The recharge function uses this context to change each bulb's own charge. Global assignments inside the function run on every call.
Dynamic reactions
Selectors can also appear in a reaction's reagents list. They match the instances supplied to that reaction.
{
"reagents": [
"Mine",
{
"id": "Stone Pickaxe",
"filter": "l(el_uuid(), 'durability') > 0",
"limit": -1,
"alias": "tools"
}
],
"result": [
{
"type": "set",
"target": {"from": "tools", "limit": -1, "name": "durability"},
"value": {"type": "computed", "expression": "l(el_uuid(), 'durability') - 10"}
},
"Stone"
]
}Exact recipes containing only element IDs have priority over dynamic recipes. Dynamic recipes are checked in definition order.
Reagent order matters. Each selector chooses from the supplied participants that remain after earlier selections. Each reagent slot must select at least one instance, and the recipe must cover all supplied participants. Matching proceeds in order. If a later slot fails, the recipe fails.
limit: -1 allows the slot to use any number of matching supplied reagents. In this example, alias: "tools" saves the chosen pickaxes for the result operations.
Aliases
alias saves a snapshot of the selected UUIDs under a name in the current reaction or event context. Later operations use from to select instances from that group.
In the mining recipe above, from: "tools" selects the pickaxes chosen as reagents. The grouped set reduces each selected pickaxe's own durability.
You can also save a selection during the operation list. An empty run_reaction saves the selector's group. The next operation uses it to repair the chosen pickaxes:
[
{
"type": "run_reaction",
"target": {"id": "Stone Pickaxe", "limit": -1, "alias": "tools"},
"reaction": []
},
{
"type": "set",
"target": {"from": "tools", "limit": -1, "name": "durability"},
"value": 100
}
]alias — optional. Names the saved group. The name reagents is reserved.from — optional. Uses an existing group's UUIDs as the selector source. id, filter, and limit apply within that group.
group('tools') returns a copy of the group's UUID array. An unknown group returns []. Removed instances are skipped when selecting from a group.
Aliases exist only in their operation context. To keep a group for later events, save its UUID array in a variable:
{
"type": "set",
"target": {"id": "Memory", "name": "saved"},
"value": {"type": "computed", "expression": "group('tools')"}
}Then select its instances:
{
"type": "call",
"function": "repair",
"target": {"filter": "el_uuid() in g('Memory', 'saved')", "limit": -1}
}Matches follow board order. When the alias is still available in the current context, use from.
Reagent groups
Every reaction has a built-in reagents group containing all participating instances. group('reagents') returns their UUIDs.
Use from: "reagents" to target participants. This example changes the charge of every Bulb participating in the current reaction:
{
"type": "set",
"target": {"from": "reagents", "id": "Bulb", "limit": -1, "name": "charge"},
"value": {"type": "computed", "expression": "l(el_uuid(), 'charge') + 10"}
}Classes
Classes example:
{
"classes": {
"demo": {"is_shining": true},
"unlit": {"background_color": "#303238", "color": "#aeb4c0", "icon_color": "#7b8494"},
"lit": {"background_color": "#fff2a6", "color": "#664400", "icon_color": "#cf8c00", "is_shining": true}
}
}background_color — element background color.color — default text color.icon_color — default icon color. An icon's own color overrides it.selection_color — selection border color. Defaults to the current text color.is_shining — optional (default: false). Enables the hover shine effect.
Colors can be hex strings or objects with red, green, blue (0–255), and optional alpha (0–1).
The built-in default class is the base. A mod's classes.default can override it. For multiple classes, later classes override earlier ones. Fields defined directly on the element override class fields. Visual display and description settings can also be shared through classes.
Events
Global events
{
"events": {
"on_start": ["Charger", "Bulb", "Bulb", "Bulb"],
"on_join": [],
"on_leave": []
}
}on_start — operations run when the mod is loaded and when the player double-clicks an empty board area with is_initial_spawning_enabled enabled.on_join — join-related operations. The current implementation runs these after a client receives board state, including state reloads.on_leave — operations run when a peer disconnects.
Global event values are operation arrays or reaction objects.
Element events
{
"events": {
"on_spawned": {"do": [], "is_enabled": true},
"on_destroyed": {"do": [], "is_enabled": true},
"on_tick": {
"is_enabled": true,
"do": [
{
"type": "set",
"target": {"id": "Bulb", "filter": "el_uuid() in g('Bulb', 'active') and l(el_uuid(), 'charge') > 0", "limit": -1, "name": "charge"},
"value": {"type": "computed", "expression": "l(el_uuid(), 'charge') - 1"}
}
]
}
}
}Place this events object inside an element definition. It is different from the mod's top-level events.
on_spawned — runs when an instance is spawned on the board. Enabled by default.on_destroyed — runs when an instance is removed during gameplay. Enabled by default.on_tick — runs at 20 ticks per second. Disabled by default.
Element event operations run on the server. is_enabled is shared by the element type.
The do field accepts an operation array or a reaction object with its own spawn settings. The same format is available in property events.
on_tick runs once per element type per tick. It uses the first instance that is available, idle, and active on the board as its context. This applies to types with global properties, local properties, or both.
For multiple local values, use a grouped set with limit: -1. For a separate sequence of actions per instance, use call.target or run_reaction.target.
Functions
Functions example:
{
"functions": {
"recharge": {
"args": {"amount": {"type": "number"}},
"result": [
{
"type": "set",
"target": {"uuid": {"type": "computed", "expression": "el_uuid()"}, "name": "charge"},
"value": {"type": "computed", "expression": "l(el_uuid(), 'charge') + arg('amount')"}
}
]
}
}
}args — optional (default: {}). Argument definitions. Each definition is an object with a type, which defaults to "any". Defined arguments must be supplied by the caller.result — the function's operation array or a reaction object.
Arguments exist only inside that function call. Use arg('amount') in expressions. Functions called without target inherit the current instance context. call.target sets it to each selected instance.
Functions can read the caller's groups. Aliases created inside a function are scoped to that call.
Expression helpers
Expressions use Godot's Expression syntax. Conditions and selector filters can use expressions directly. For other calculated values, use {"type": "computed", "expression": "..."}.
| Helper | Returns |
|---|---|
g('Element', 'property') | A global property, or null if missing. |
l(uuid, 'property') | An instance's local property, or null if missing. |
el_uuid() | The current instance UUID, or "" without an instance context. |
el_id() | The current element type ID, or "" without an instance context. |
group('alias') | A copy of a context group's UUID array, or [] if missing. |
arg('name') | A function argument, or null if missing. |
tps() | The fixed tick rate: 20. |
time() | Milliseconds since the engine started. |
quantity('Element') | Number of instances of that type on the board. |
player_count() | Number of connected players, including the host. |
who() | The current actor's multiplayer ID. |
el_uuid() and el_id() refer to each candidate while a selector filter runs, each selected instance in targeted operations, and the current instance in element display/event contexts. Use a targeted operation to choose the current instance within a reaction result.
Expressions also support built-in functions such as min, max, and randf, array indexing, and array methods such as size() and pick_random().
See the examples for complete mods.