Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

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.

Registrymanifold:game-rule
Filesdata/game-rules/*.ron, *.update.ron, *.final.ron
Sidesboth: the server and every client load it, and the handshake’s data hash covers it
Readsnothing
ContractGame rules, data stage

Entry

A record, written GameRule(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe rule’s key, <mod-id>:<name>. The console accepts the bare name when only one mod declares it.
kindRuleKindyesThe value’s type and limits.
defaultrule-valueyesThe 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).

VariantWrittenDescription
BoolBooltrue or false.
IntInt(min: .., max: ..)An integer in min..=max.
FloatFloat(min: .., max: ..)A finite number in min..=max.
StringString(max_len: ..)Text of at most max_len bytes.
KeyKey(registry: ..)A key of another registry, such as one of its preset entries.
EnumEnum([string])One of the listed names: lower-case letters, digits, -, _ and ., at least one.

Int fields:

FieldTypeRequiredDefaultDescription
mini64nono limitThe smallest value.
maxi64nono limitThe largest value.

Float fields:

FieldTypeRequiredDefaultDescription
minf32nono limitThe smallest value.
maxf32nono limitThe largest value.

String fields:

FieldTypeRequiredDefaultDescription
max_lenu32no256The longest text, in bytes, 1 to 4096.

Key fields:

FieldTypeRequiredDefaultDescription
registrystringyesThe 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.