Variations
Variations is the one API a layer gets. It's always there: you don't need to
load it. See The API for how the pieces fit.
A point is the name the runtime checks before a change, such as
rules.player.speed, zones, items or slots.player.
Rules
| Call | Gives back | What it does |
set_rule(key: String, value: Variant) | bool | Sets the rule key. Guarded by rules.<key>. false if refused |
rule(key: String, fallback: Variant = null) | Variant | The rule's value, or fallback if nobody set it |
rules() | Dictionary | A copy of every rule, by key |
Zones
| Call | Gives back | What it does |
register_zone(zone_name: String, build: Callable) | bool | Adds a zone, or replaces one with the same name. build returns the zone's node. Guarded by zones |
zones() | Dictionary | Every zone by name: {build, by}, where by is the slug of the layer that registered it |
Items
| Call | Gives back | What it does |
register_item(item_name: String, build: Callable) | bool | Adds an item, or replaces one with the same name. Guarded by items |
items() | Dictionary | Every item by name: {build, by} |
make_item(item_name: String) | Node3D | Builds one of the item. Any layer may place any item. For a 2D item, use items()[name].build.call() |
Slots
| Call | Gives back | What it does |
fill_slot(slot: String, build: Callable) | bool | Fills the slot. Guarded by slots.<slot> |
slot(slot_name: String) | Dictionary | {build, by}, or {} if the slot is empty |
Events
| Call | Gives back | What it does |
emit_event(event_name: String, payload: Dictionary = {}) | nothing | Sends the event to every layer, through the event signal |
Asking
| Call | Gives back | What it does |
allowed(point: String) | bool | Whether the layer being loaded may change point. The root may change anything |
is_root_layer() | bool | Whether the layer being loaded is the root |
credits() | Array | {slug, name, creator} for each layer, root first |
Signals
| Signal | When |
event(name: String, payload: Dictionary) | Any layer, or the runtime, sends an event. The runtime sends start once every layer has loaded |
rule_changed(key: String, value: Variant) | A rule is set |
Variations.event.connect(_on_event)
Variations.rule_changed.connect(_on_rule_changed)