mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 06:23:37 -05:00
Update documentation
This commit is contained in:
parent
b30ee492be
commit
ef2da9d40c
1 changed files with 13 additions and 7 deletions
20
README.md
20
README.md
|
@ -13,10 +13,19 @@ var VirtualMachine = require('scratch-vm');
|
||||||
var vm = new VirtualMachine();
|
var vm = new VirtualMachine();
|
||||||
|
|
||||||
// Block events
|
// Block events
|
||||||
|
workspace.addChangeListener(function(e) {
|
||||||
|
// Handle "tapping" a block
|
||||||
|
if (e instanceof Blockly.Events.Ui && e.element === 'click') {
|
||||||
|
var stackBlock = workspace.getBlockById(e.blockId).getRootBlock().id;
|
||||||
|
vm.runtime.toggleStack(stackBlock);
|
||||||
|
// Otherwise, pass along to the block listener
|
||||||
|
} else {
|
||||||
|
vm.blockListener(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// UI events
|
// Run threads
|
||||||
|
vm.runtime.start();
|
||||||
// Listen for events
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Standalone Build
|
## Standalone Build
|
||||||
|
@ -35,6 +44,7 @@ make build
|
||||||
## Abstract Syntax Tree
|
## Abstract Syntax Tree
|
||||||
|
|
||||||
#### Overview
|
#### Overview
|
||||||
|
The Virtual Machine constructs and maintains the state of an [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (AST) by listening to events emitted by the [scratch-blocks](https://github.com/LLK/scratch-blocks) workspace via the `blockListener`. At any time, the current state of the AST can be viewed by inspecting the `vm.runtime.blocks` object.
|
||||||
|
|
||||||
#### Anatomy of a Block
|
#### Anatomy of a Block
|
||||||
```json
|
```json
|
||||||
|
@ -78,7 +88,3 @@ make test
|
||||||
```bash
|
```bash
|
||||||
make coverage
|
make coverage
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
|
||||||
make benchmark
|
|
||||||
```
|
|
||||||
|
|
Loading…
Reference in a new issue