(Redirected from Extension)

SandCastleIcon.png This page has links to websites or programs not hosted or created by Scratch or Wikipedia. Remember to stay safe while using the Internet, as we can't guarantee the safety of other websites.
Archive.png
The subject of this article or section has changed dramatically and requires updating. Please keep in mind that some of the information or images may not be accurate or relevant to the current version of Scratch, the Scratch website, or the article subject. (May 2015)
Clock.png This article will need to be updated upon the release of Scratch 3.0. If you are an editor, please update this when Scratch 3.0 is released. If you are an editor, please create the post-3.0 version at Scratch Wiki:3.0 Articles/Scratch Extension.
There may already be ongoing discussion about how to do so on its talk page.

Scratch Extensions make it possible to connect Scratch projects with external hardware (such as LEGO WeDo or PicoBoard) or sources of information on the web. They add a collection of command and reporter blocks that can be used to interact with a particular device or data source. When an extension is enabled, its blocks appear in the "More Blocks" palette.

The LEGO WeDo Javascript extension blocks

To load an extension, go to the "More Blocks" category in the Scratch Editor and click "Add an Extension."

The button to add an extension in Scratch 2.0.

There are two types of extensions in Scratch 2.0: hardware and web.

Writing Extensions

There are two mechanisms to extend Scratch 2.0, either with HTTP requests or Javascript.

Javascript Extensions

This extension mechanism uses Javascript to create the extensions. The official documentation for creating this kind of extension can be found on the ScratchX Github wiki, along with sample extension code.

The current extensions available in the online editor, like the PicoBoard extension, are Javascript extensions.

HTTP Extensions

Note Note: This mechanism works only with the offline editor.
The A4S (Arduino for Scratch) experimental HTTP extension.

Scratch 2.0 cannot interact with hardware devices directly. Instead, hardware extensions come with a helper app — a separate application that the user must install and run on their computer. Scratch communicates with the helper app via HTTP requests, and the helper app talks to the hardware. In the future, some extensions may package their helper apps as browser plugins.

A document (last updated: September 2013) has been drafted for Scratch 2.0 HTTP extension developers to describe the extension description file format — the protocol used to communicate between Scratch extension helper apps, and the extension development process. This specification is still preliminary and may change.

The Scratch 2.0 extension mechanism is still under development, and the Scratch Team is still figuring out how the extensions will be shared and distributed.

Distributing Extensions

An extension distribution strategy is still being worked out. The Scratch team will probably host a small library of "supported" extensions. Users will be able to browse and select extensions from this library from within the Scratch editor. Supported extensions would be checked for quality and safety by the Scratch team. There are likely be strict criteria for including an extension in the Scratch-team supported extensions library, such as command set clarity and ease of use, size of the potential audience, widespread availability of any associated hardware, and a long-term commitment to support the extension.

Projects with experimental extensions cannot be shared on the Scratch website and will result in a pop-up message whenever a user tries to share a project with experimental extensions. Extension developers can share their extensions by distributing Scratch 2 project files (.sb2). Users can then use the "File > Upload from computer" command to import the project that uses the extension.

ScratchX

ScratchX is a gallery of experimental extensions that one can try out on the ScratchX website. The website can be found here. There are multiple Scratch extensions on ScratchX.

See Also