Update README.md

This commit is contained in:
He4eT 2021-02-24 18:42:30 +05:00
commit c44c2f4f70

View file

@ -6,7 +6,11 @@ Can be used in Node.js or in a web browser.
## Usage ## Usage
This repository includes examples of [stdio interface implementation](https://github.com/He4eT/cheap-glkote/blob/master/src/stdio.js) and [integration with Emglken](https://github.com/He4eT/cheap-glkote/blob/master/tests/player.stdio.js). This repository includes examples of [stdio interface implementation](https://github.com/He4eT/cheap-glkote/blob/master/src/stdio.js) and [integration with Emglken](https://github.com/He4eT/cheap-glkote/blob/master/tests/player.stdio.js).<br>
You can try this version with `npx`:
```
npx cheap-glkote path/to/storyfile
```
### Initialization ### Initialization
```js ```js
@ -15,8 +19,9 @@ const { glkInterface, sendFn } = CheapGlkOte(handlers [, loggers])
### Input ### Input
```js ```js
sendFn('open door') sendFn('open door', windowObject)
``` ```
You can received `windowObject` in `onUpdateWindows` handler.<br>
You should respect input type setted by `onUpdateInputs`. You should respect input type setted by `onUpdateInputs`.
### Output and lifecycle ### Output and lifecycle
@ -27,14 +32,9 @@ const handlers = {
* It's time to prepare the user interface. * It's time to prepare the user interface.
*/ */
}, },
onExit: () => { onUpdateWindows: windows => {
/** /**
* Game is over. * Game wants to change the number of windows.
*/
},
onUpdateContent: messages => {
/**
* Process the game output here.
*/ */
}, },
onUpdateInputs: type => { onUpdateInputs: type => {
@ -43,6 +43,11 @@ const handlers = {
* Supported types: 'char', 'line'. * Supported types: 'char', 'line'.
*/ */
}, },
onUpdateContent: messages => {
/**
* Process the game output here.
*/
},
onDisable: () => { onDisable: () => {
/** /**
* Game wants to disable user interface. * Game wants to disable user interface.
@ -66,6 +71,11 @@ const handlers = {
/** /**
* Game wants to write the contents in the file. * Game wants to write the contents in the file.
*/ */
},
onExit: () => {
/**
* Game is over.
*/
} }
} }
``` ```