Scriber.App (Scriber v0.1.2)

Copy Markdown View Source

The drafter application: layout, key handling, and where the game and the console meet.

The run is a Scriber.Game in a Cauldron2D.World of this player's own, started with tick: :on_input: every key becomes an action sent as input, the world steps once on it, and the frame it sends back is what is drawn. This module translates a keystroke into an action and a game into a component tree, and owns the two side effects a turn can have — writing the next stratum's files and switching the ambience — from the events the world sends with each frame.

Modes

The console is a mode of this application, not a component. While :console? is true every key goes to the prompt, including the ones that would otherwise move or quit, and only Esc closes it. Scriber.Console can spend shards and shards live in the world, so a purchase or a sale is an action the console leaves pending and this module sends the world, which applies it.

Keys

In the Lattice:

h j k l / arrows   move orthogonally
q e z c            move diagonally (y u b n also work)
. or s             wait
a                  apply a patch
f / x              throw a fuse / a decoy: aim with the move keys, Tab picks the next
                   creature in view, Enter throws, Esc puts it away
p                  trigger a pulse: everything at arm's reach thrown back and stunned
Enter              use the tile underfoot: a console, or a stair
>                  descend
0                  take up bare hands
1-4                take up a bought weapon, in the order the forge lists them
m                  toggle mute
r                  begin another run, once the current one has ended
Q or Shift-q       quit
Ctrl-c             quit

At the console, every printable key types; Enter submits, Backspace rubs out, Esc returns to the Lattice.

Gate polling

A timer checks periodically whether Scriber.Lattice has recorded this stratum's gate as open, and sends the world :unseal when it has. The console is therefore not the only thing that can open a gate — anything that writes the marker will do.

Mount props

Summary

Functions

Take the world's frame: its view is the game drawn from now on, and its events are the turn's side effects — {:descended, depth} prepares the stratum's files and switches the ambience.

Open the game's gate when Scriber.Lattice reports this stratum unsealed on disk.

Functions

keybindings()

on_message(arg1, state)

Take the world's frame: its view is the game drawn from now on, and its events are the turn's side effects — {:descended, depth} prepares the stratum's files and switches the ambience.

on_timer(arg1, state)

Open the game's gate when Scriber.Lattice reports this stratum unsealed on disk.

Fires on every tick of the :seal interval and returns the state unchanged unless the gate is recorded open on disk but still shut in the game. Any other timer is ignored.