1.0.4 • Published 6 years ago

oasys-interpreter v1.0.4

Weekly downloads
4
License
Unlicense
Repository
-
Last release
6 years ago
This program implements the OASYS VM for text adventure games. This
program is public domain.

The exported function is a generator function, which takes two arguments.
The first argument is mandatory and is a Buffer or Uint8Array with the
contents of the binary story file (it can be either 16-bit or 32-bit, and
it can be either small-endian or big-endian). The second argument is an
options object and is optional. Valid options include:

  .random
    A function taking a positive integer N and returning a number in the
    range from 0 to N-1. The number should be randomized.

To initialize, first you should call .next() with no arguments. After
that, it will yield one of the following:

  String
    Display this string and request input (the prompt is part of this
    string). Provide the requested input next.

  Uint8Array
    A request to save the game. You can provide null or anything; it
    doesn't care. What the interpreter wishes to do with the data is
    up to you.

  Null
    A request to restore a saved game. Provide either null (if the user
    does not wish to restore a saved game or if there is no saved game
    to restore), or provide a Uint8Array that was yielded (or another
    Uint8Array with the same contents) in order to restore that save game.

If it returns rather than yielding, the game is finished.

Throw true into the generator to restart the game.

There is a example file "run.js", although it doesn't implement save game.