|This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.|
|This article has links to websites or programs not trusted by Scratch or hosted by Wikipedia. Remember to stay safe while using the internet, as we cannot guarantee the safety of other websites.|
Mesh was a feature in Scratch 1.4 allowing users to interact over a computer network. Mesh allows projects to share variables and broadcasts, opening up a surprisingly large field of new project opportunities since technically sharing these two features is actually all that is needed to write most interacting programs.
How to get Mesh
There were three ways to access Mesh in Scratch 1.4:
Using the 1.4 Beta
The early beta version of Scratch 1.4 had Mesh enabled. This version was shared at the first formal Scratch Day. Only a few Scratchers were able to use this version. Mesh was disabled in the public release candidate of June of 2009.
Using a Scratch Mod
This requires the use of the system browser.
- Shift-click the R in the Scratch logo.
- Select "turn fill screen off".
- A grey space will appear arround Scratch. Click on it and select "open…" followed by "browser".
- The system browser will appear. Select "Scratch-UI-Panes", followed by "ScratchFrameMorph", "menu/button actions", and "addServerCommandsTo:".
- The code of this method will appear below. Find
t2 ← trueand change it to
t2 ← false.
- Right-click (if you are using Microsoft Windows) or hold down Control and click (otherwise) on the system browser and select "accept".
- Enter your initials and click "accept".
- Close the system browser.
- Shift-click the R again and select "turn fill screen on".
- If you would like to keep using Mesh, Shift-click the R and select "save image for end-user" to save the image file.
- If Mesh has been saved but is no longer wanted, repeat the steps but change
- To get the ← symbol, press _ ( + ).
How to Host and Join Mesh Sessions
Once Mesh has been enabled, Shift-clicking Share in the menu bar will reveal two new items: Host Mesh and Join Mesh.
- Host Mesh begins a Mesh session and shows the user's local IP address. (This address is useful only for connecting over a local area network.)
- Join Mesh joins a Mesh session given an IP address.
If the IP address of the computer has been forgotten, Share can be Shift-clicked and the item Show IP address selected.
A great number of Scratch processes can be connected to a single Mesh session.
Connecting Over the Internet
Normally, Mesh only works over a LAN (local area network), but it can be used over the internet by forwarding port 42001 on the router of the hosting user, which allows users to play Scratch projects together from across the world. (A program such as Hamachi could also be used, but this must be installed on every participant's computer.)
The Scratch 1.4 beta had a built-in system to allow Mesh to be used across the Internet without external programs or configuration.
How to Program with Mesh
During a Mesh session:
- Broadcasts are received on all Scratch processes.
- The for-all-sprites variables of each Scratch process can be read by the others.
A broadcast created in one Scratch process does not appear on the others until it is first sent, but one can also just make a broadcast with the same name.
The () Sensor Value block is used to find the value of a variable on another Scratch process. (The Variables palette only shows those variables of its Scratch process.) For example, this script could be used in one project:
when flag clicked ask [What is my name?] and wait set [name v] to (answer) broadcast [greet v]
and this in another:
when I receive [greet v] say (join [Hello, ] ([name v] sensor value :: sensing)) for (2) secs
Broadcast () and Wait does not wait for scripts in other Scratch processes.
Sending and Receiving Lists
To share a list with Mesh, one can use broadcasts instead of Add () to (), Delete () of (), etc., or one can encode the list as a string and store it in a variable, which could be done by using the following script in the sending project:
when I receive [send list v] set [# v] to  set [result v] to  repeat (length of [list v]) set [result v] to (join (join (result) (item (#) of [list v])) [,]) change [# v] by (1) end broadcast [list is ready v]
and the following in the receiving project:
when I receive [list is ready v] delete (all v) of [list v] set [# v] to  set [item v] to  repeat (length of ([result v] sensor value :: sensing)) if <(letter (#) of ([result v] sensor value :: sensing)) = [,]> :: control add (item) to [list v] set [item v] to  else set [item v] to (join (item) (letter (#) of ([result v] sensor value :: sensing))) end change [# v] by (1) end
(This works as long as none of the items contain commas.)
A lot of things can go wrong when enabling and using Mesh, so here's a few things to check:
- Make sure there is a period (.) after
falsein the system browser.
- If changes made in the system browser were not saved, Mesh will no longer work when Scratch is closed.
- If one would like to use Mesh over the internet:
- Make sure port 42001 has been forwarded.
- Make sure to use the host's internet address and not its local IP address.
- If one is using a program such as Hamachi, make sure the Hamachi IP address is used rather than the computer's IP address.
Internals of Mesh
Mesh is based upon remote sensor connections; there is effectively no difference between hosting Mesh and enabling remote sensor connections.
Mesh need not be hosted by Scratch; FireMMO is an example of remote sensor connections used for multiplayer servers.
- Mesh - how to get it, use it, and program with its features
- Mesh Tutorial Project
- Scratch 1.4 Installation Page
- johnadmin. (7/6/2009). "the experimental "mesh" feature was removed." ar-post:131585