# Install VM - the logic part. Sends state to the GUI
git clone https://github.com/LLK/scratch-vm.git
cd scratch-vm
nvm use # if using nvm for node version management
npm install
npm link
# Install GUI - the visual part
git clone https://github.com/LLK/scratch-gui.git
cd scratch-gui
npm install
npm link scratch-vm # use your local version
npm start # see localhost:8601
Setup an extension using the extension guide: Extension Guide
Your extension should live under scratch-vm/src/extensions/scratch3_myId/index.js
where myId
is the name of your extension.
In scratch-vm/src/extension-support/extension-manager.js
add:
const builtinExtensions = {
...
myId: () => require('../extensions/scratch3_myId')
};
In scratch-gui/src/lib/libraries/extensions/index.jsx
, add your extension to the export default
list. You can copy an existing example, but it is import that the extensionId
field matches myId
above.
extension.js
, move it to scratch-vm/src/extensions/scratch3_test/index.js
scratch-vm/src/extension-support/extension-manager.js
const builtinExtensions = {
...
test: () => require('../extensions/scratch3_test')
};
scratch-gui/src/lib/libraries/extensions/index.jsx
{
name: (
<FormattedMessage
defaultMessage="Test blocks"
description="Name for the 'Test Blocks' extension"
id="gui.extension.testBlocks.name"
/>
),
extensionId: 'test',
iconURL: musicIconURL,
insetIconURL: musicInsetIconURL,
description: (
<FormattedMessage
defaultMessage="Test things"
description="Description for the 'Test Blocks' extension"
id="gui.extension.testBlocks.description"
/>
),
featured: true
},
scratch-gui
with npm start
go run main.go
. This should print “Hello, world!” at http://localhost:9999https://sheeptester.github.io/scratch-gui can be used to run scratch extensions without running scratch in development locally. See the source for more information.
extension-sheeptester.js
shows the differences needed in the extension file. This file needs to be hosted somewhere (you can use GitHub pages for that using this simple tutorial).
As an example, extension-sheeptester.js
is hosted on the GitHub pages for this repository here, and can be run in the browser by going to https://sheeptester.github.io/scratch-gui/?url=https://coderdojobrighton.github.io/scratch-extension-tutorial/extension-sheeptester.js