Bitflinger Games docs

The API

Every layer talks to the game through Variations, and it deals in five kinds of thing. The runtime stores them and checks who may change them. The root's own script gives them meaning, by reading the rules and building the zones, items and slots.

KindWhat it isChange or add itRead or use itThe point that guards it
RuleA named value, such as player.speedset_rule(key, value)rule(key, fallback), rules()rules.<key>
ZoneA function that builds a piece of the worldregister_zone(name, build)zones()zones, all of them or none
ItemA function that builds one thing to place, such as a coinregister_item(name, build)make_item(name), items()items, all of them or none
SlotThe one thing the root asks for by name, such as the playerfill_slot(name, build)slot(name)slots.<name>
EventA name and a payload, sent to every layeremit_event(name, payload)connect to the event signalnothing: events are open to all

A point is the name the runtime checks before a change: rules.sky.time, zones, slots.player. The root's open list and every layer's seal list are lists of points.

Yes or no

A call that changes something returns true when it took effect and false when it was refused. A refusal is not an error. The game keeps running and the refusal is listed in the game's report under denied.

if not Variations.set_rule("world.gravity", 6.0):
	Variations.emit_event("hud.message", {"text": "Gravity is sealed here"})

Looking before you act

CallWhat it tells you
allowed(point)Whether your layer may change that point, for example allowed("rules.sky.time")
is_root_layer()Whether your layer is the root
credits()Who made each layer, root first

Signals

Those calls and signals are the whole API. The Reference lists each one with its arguments.

A layer's life

  1. The runtime loads each layer's files, root first.
  2. It runs each layer's entry script once, in the same order. This is where you call set_rule, register_zone and the rest, usually in _ready.
  3. When every layer has run, the runtime sends the start event. The root builds the world from the zones, items and slots it now has.
  4. The game plays. Layers hear events and send their own.

Starter World sends world.ready when it has finished building, which is the first moment the player and the world exist.