mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-05 02:54:05 -04:00
parent
29a595345a
commit
220d614a9d
3 changed files with 34 additions and 18 deletions
47
README.md
47
README.md
|
@ -6,6 +6,8 @@
|
|||
[](https://david-dm.org/LLK/scratch-vm#info=devDependencies)
|
||||
|
||||
## Installation
|
||||
This requires you to have Git and Node.js installed.
|
||||
|
||||
In your own node environment/application:
|
||||
```bash
|
||||
npm install https://github.com/LLK/scratch-vm.git
|
||||
|
@ -17,27 +19,23 @@ cd scratch-vm
|
|||
npm install
|
||||
```
|
||||
|
||||
## Setup
|
||||
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
|
||||
```js
|
||||
var VirtualMachine = require('scratch-vm');
|
||||
var vm = new VirtualMachine();
|
||||
## Development Server
|
||||
This requires Node.js to be installed.
|
||||
|
||||
// Block events
|
||||
workspace.addChangeListener(vm.blockListener);
|
||||
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
|
||||
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
|
||||
|
||||
// Run threads
|
||||
vm.runtime.start();
|
||||
```
|
||||
## Development Server and Playground
|
||||
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file. To start the server, run:
|
||||
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file.
|
||||
|
||||
## Running the Development Server
|
||||
Open a Command Prompt or Terminal in the repository and run:
|
||||
```bash
|
||||
make serve
|
||||
npm start
|
||||
```
|
||||
and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
|
||||
Or on Windows:
|
||||
```bash
|
||||
StartServerWindows.bat
|
||||
```
|
||||
|
||||
## Playground
|
||||
To run the Playground, make sure the dev server's running and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
|
||||
|
||||

|
||||
|
||||
|
@ -55,6 +53,21 @@ make build
|
|||
</script>
|
||||
```
|
||||
|
||||
## How to include in a Node.js App
|
||||
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
|
||||
```js
|
||||
var VirtualMachine = require('scratch-vm');
|
||||
var vm = new VirtualMachine();
|
||||
|
||||
// Block events
|
||||
workspace.addChangeListener(vm.blockListener);
|
||||
var flyoutWorkspace = workspace.toolbox_.flyout_.workspace_;
|
||||
flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
|
||||
|
||||
// Run threads
|
||||
vm.runtime.start();
|
||||
```
|
||||
|
||||
## Abstract Syntax Tree
|
||||
|
||||
#### Overview
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue