~kylep/visual-cell-lang

eff38cb1c105c08d8142edad4abe2b390b5e6a19 — Kyle Perik 1 year, 7 months ago 274b09c
Update readme
1 files changed, 6 insertions(+), 41 deletions(-)

M README.md
M README.md => README.md +6 -41
@@ 45,14 45,13 @@ The UI takes 100% inspiration from the fantastic game [Mindustry](https://mindus
All interaction takes place with the mouse alone:
- use the dropdown below to add new cells
- drag and drop cells or conveyors
- click and drag to add a new conveyor
- right click to remove conveyors or boxes
- click and drag from cell outputs to inputs to form a connection
- right click to remove connections or boxes
- user the slider at the top to change the overall speed

Your program is autosaved every 5 seconds or so.

At this time there is no way to generate new box definitions on the fly, or share
with others, I hope to add this soon.
To add your own cell definitions, setup a local environment and checkout [Cells](#cells).
There's a code editor on the side that you can use to define your own cells. Checkout the documentation here: [Lang](docs/lang.md)

## Developer setup



@@ 65,44 64,10 @@ npm run serve

This will start the server, then you can connect at http://localhost:8080

## Cells

Cells are defined within `src/codebox.js`.

Each cell definition consists of an object which
contains the following keys:
- inputs
  - A list of strings indicating what inputs the cell takes
- outputs
  - A list of strings indicating what outputs the cell emits
- data
  - Defines the initial internal state of the cell, if applicable
- handlers
  - Provides a function for every input which gives instructions on how to respond to any
  given input

Optionally a special more safe language can be run within cells. See documentation for the embeded language here: [Lang](docs/lang.md).

### Input handlers

Handlers are what define the functionality of a given cell.
The handler function is called immediately upon receiving an input of that type.

(Ideally handler functions would be defined in some kind of bytecode with the specification
as defined in [Background](#background) to prevent running forever or accessing resources, performing side effects, etc, while being portable)

The input to a handler function is a single object which can be deconstructed into 3 parts
- value
  - The value of the input receieved
- out
  - Provides a function for each output, when called with a value triggers an output to be emit
  - Like so: `out.a(5)`
- data
  - Provides the current state of the box
  - You can mutate this data directly

## Example

TODO: Update this for the new lang

Let's breakdown an example of a basic snake game.

To start, we begin with an empty object in `codebox.js`