Archive.png This article or section documents a feature not included in the current version of Scratch (2.0). It is only useful from a historical perspective.
SandCastleIcon.png This page has links to sites outside of the Scratch website and Wikipedia. Always remember to stay safe when using the Internet, since we can't guarantee the safety of other sites.

Mesh is a method of having multiple Scratch projects interact, even if they are on different computers. 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 are three ways to access Mesh in Scratch 1.4:

Mesh by Beta 1.4

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 get this version. The public beta from October had it enabled as well. Mesh could be enabled by shift-clicking on the Share button.

An IMAGE File of this build can be downloaded here.

Mesh by External Application

Many Scratch modifications come with Mesh already included, without having to alter anything. One mod intended solely for the enabling of Mesh is available for download here.

Snap! and Panther also come with Mesh pre-enabled; the latter has many blocks to use mesh.

Mesh by Modification of Scratch

What the System Browser should look like after editing it to activate Mesh.

This requires editing of Scratch's System Browser.

  1. Shift-click the R in the Scratch logo.
  2. Select turn fill screen off.
  3. A white area at the bottom and right side of the Scratch program will appear. Click on the white area and select open....
  4. Select 'browser.
  5. The System Browser will appear. Select Scratch-UI-Panes - ScratchFrameMorph - menu/button actions - addServerCommandsTo:.
  6. Change the "t2 ← true" text in the code to "t2 ← false".
  7. Right-click on the System Browser and select accept. (If on Mac or Linux, then hold the Control key and then click).
  8. Enter in initials and click accept.
  9. Close the System Browser.
  10. Shift-click the R again and select turn fill screen on.
  • If edits to the System Browser need to be saved, Shift-click the R and select save image for end-user to save the IMAGE file.
  • If Mesh has been saved but is not wanted anymore, the steps to enable Mesh can be reverted to remove it.
  • To get the ← symbol, press _ ( [Shift] + [-] ).

How to Host and Join Mesh sessions

Shift-clicking the Share button with Mesh enabled allows hosting and joining Mesh sessions.

A Scratch program that has Mesh available looks like an un-edited Scratch program. However, Shift-clicking Share will reveal two new buttons: Host Mesh and Join Mesh.

  • Host Mesh begins a Mesh session.
  • Join Mesh joins a Mesh session.

To host Mesh:

  1. Select Host Mesh.
  2. The hosting computer's IP address will be shown. However, this is not the only IP address that can be used to access the Mesh session, as others may need to be used (e.g. external IP addresses or one provided by another program).

To join a Mesh session:

  1. Select Join Mesh.
  2. Enter in the IP address of the computer that is hosting the Mesh session.

If the IP address of the computer has been forgotten, the Share button can be Shift-clicked and the button Show IP address selected.

A Mesh session can contain unlimited Scratch programs.

Connecting Over the Internet

SandCastleIcon.png This page has links to sites outside of the Scratch website and Wikipedia. Always remember to stay safe when using the Internet, since we can't guarantee the safety of other sites.

Normally, Mesh only works over a LAN (Local Area Network); however, certain programs (such as LogMeIn Hamachi) allow users to create their own Mesh network, thereby allowing users from across the world to play Scratch projects together.

If others need to join a Mesh session that one is hosting without using a program or configuring anything on their end, forward port 42001 on one's router. For more information, see port-forwarding on Wikipedia or search for "port-forwarding" on the Internet. This can also be done with a port-forwarding program such as grappl.

The beta of 1.4 had a built-in system to allow Mesh to be used across the Internet without external programs or configuration.

How to Program With Mesh's Features

Programming with Mesh is the same as programming without it - the interface is the same as always. But when a Mesh session is in activity, it changes:

  • Broadcasts are received on all Scratch programs.
  • Each Scratch program's variables are available for use on the others.

If a broadcast is created on one Scratch program, it does not show up in the broadcast list on the other Scratch programs - however, broadcasts will still be received on all Scratch programs. To create a broadcast for use in all Scratch programs, the broadcast has to be made on each Scratch program.

To use variables that are from a different Scratch program, the () Sensor Value block can be used - all the variables from the other Scratch programs will show in the drop-down menu. That is the only place they will be available - the Variables section will only show the variables made on the Scratch program that is being used.

Sending and Receiving Lists

To send a list over Mesh, use this to transmit:

when I receive [send list v]
set [# v] to [1]
repeat (length of [list to send v])
set [list v] to (join (list) (join (|) (item (#) of [list to send v]))
change (#) by (1)
end
broadcast [list is ready v]

To receive a list, use this:

when I receive [list is ready v]
set [# v] to [1]
repeat (length of ([list v] sensor value))
if <(letter (#) of ([list v] sensor value)) = []>:: control
add [] to [List v]
else
replace item (last v) of [List v] with (join (item (last v) of [List v]) (letter (#) of ([list v] sensor value))

Troubleshooting

A lot of things can go wrong when activating and using Mesh, so here's a few things to check:

  • Make sure to shift-click share rather than just clicking it to access Mesh
  • Make sure there is a period (.) after 'false' in the System Browser
  • If changes to the System Browser were not saved, next time Scratch is opened, Mesh does not work anymore
  • If a program such as Hamachi is installed, make sure the Hamachi IP is used rather than the computer's IP
  • Scratch sometimes gives an incorrect IP; find out the correct IP through other means
  • Make sure connection is happening over a LAN network rather than over the Internet (unless the router has been properly configured)
  • Make sure that the variables and broadcasts are called exactly the same (it's case-sensitive) in each project

Internals of Mesh

Mesh, in its rawest form, is simply remote sensor connections. As a matter of fact, any program that communicates through remote sensor connections can communicate through Mesh with no modifications. Instead of enabling remote sensor connections, one would host Mesh.

Because of remote sensor connections, any broadcast or variable gets sent to any computer listening on the socket (it is mainly this loophole that allows for 4 player meshes). Mesh "servers" take advantage of remote sensor connections, as remote sensor connections allows for multiplayer. FireMMO is a good example of remote sensor connections used for multiplayer servers.

See Also

External Links