From ef2da9d40c914569dcd18d946b2179f3ac170906 Mon Sep 17 00:00:00 2001 From: Andrew Sliwinski Date: Tue, 10 May 2016 12:12:31 -0400 Subject: [PATCH] Update documentation --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 86cff25c5..e052d4755 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,19 @@ var VirtualMachine = require('scratch-vm'); var vm = new VirtualMachine(); // 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 - -// Listen for events +// Run threads +vm.runtime.start(); ``` ## Standalone Build @@ -35,6 +44,7 @@ make build ## Abstract Syntax Tree #### 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 ```json @@ -78,7 +88,3 @@ make test ```bash make coverage ``` - -```bash -make benchmark -```