data/game-rules/
A game rule: a typed world setting, such as whether the sun moves or how many creatures may wander. A rule is declared once with its type and default; a world then sets values for the whole world or per world space with /gamerule, and the values are saved and sent to every client. Another mod changes a default by patching the rule’s default.
| Registry | manifold:game-rule |
| Files | data/game-rules/*.ron, *.update.ron, *.final.ron |
| Sides | both: the server and every client load it, and the handshake’s data hash covers it |
| Reads | nothing |
| Contract | Game rules, data stage |
Entry
A record, written GameRule(..); the name before the parentheses is optional.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | yes | The rule’s key, <mod-id>:<name>. The console accepts the bare name when only one mod declares it. | |
kind | RuleKind | yes | The value’s type and limits. | |
default | rule-value | yes | The value a world has until it sets one, of the type kind gives. |
Example
From tools/test-mods/delivery-probe/data/game-rules/delivery.ron:
(
id: "delivery-probe-mod:enabled",
kind: Bool,
default: true,
)
Types
RuleKind
A game rule’s type. A kind whose limits are all optional may be written bare (Int).
| Variant | Written | Description |
|---|---|---|
Bool | Bool | true or false. |
Int | Int(min: .., max: ..) | An integer in min..=max. |
Float | Float(min: .., max: ..) | A finite number in min..=max. |
String | String(max_len: ..) | Text of at most max_len bytes. |
Key | Key(registry: ..) | A key of another registry, such as one of its preset entries. |
Enum | Enum([string]) | One of the listed names: lower-case letters, digits, -, _ and ., at least one. |
Int fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
min | i64 | no | no limit | The smallest value. |
max | i64 | no | no limit | The largest value. |
Float fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
min | f32 | no | no limit | The smallest value. |
max | f32 | no | no limit | The largest value. |
String fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
max_len | u32 | no | 256 | The longest text, in bytes, 1 to 4096. |
Key fields:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
registry | string | yes | The registry the key names (<mod>:<registry>). A rule loaded by both sides may not name a server-only registry. |
Value forms used here: rule-value.