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.
Mesh by External Application
Mesh by Modification of Scratch
This requires editing of Scratch's System Browser.
- Shift-click the R in the Scratch logo.
- Select turn fill screen off.
- A white area at the bottom and right side of the Scratch program will appear. Click on the white area and select open....
- Select 'browser.
- The System Browser will appear. Select Scratch-UI-Panes - ScratchFrameMorph - menu/button actions - addServerCommandsTo:.
- Change the "t2 ← true" text in the code to "t2 ← false".
- Right-click on the System Browser and select accept. (If you are on a Mac or using Linux, then you will need to hold the Control key and then click).
- Enter in your initials and click accept.
- Close the System Browser.
- Shift-click the R again and select turn fill screen on.
- If you wish to save the edits to the System Browser, 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
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 allows you to join a Mesh session.
To host Mesh:
- Select Host Mesh.
- 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 you may want to use others (like your external IP address or one provided by another program).
To join a Mesh session:
- Select Join Mesh.
- 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
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.
|Warning:||The Scratch Wiki does not guarantee the safety of any external programs.|
If you want to be able to let others join a Mesh hosted by you without using a program or configuring anything on their end, forward port 42001 on your router. For more information, see port-forwarding on Wikipedia or search for "port-forwarding" on the Internet.
The beta of 1.4 had a built-in system to allow Mesh to be used across the Internet without external programs or configuration. (A Scratcher connected with his friend in Wisconsin while using it at Scratch Day.)
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.
A lot of things can go wrong when activating and using Mesh, so here's a few things to check:
- Make sure you shift-click share rather than just clicking it to access Mesh
- Make sure there is a period after 'false' in the System Browser
- If you didn't save your changes to the System Browser, next time you open Scratch, Mesh doesn't work anymore
- If you have installed a program such as Hamachi, make sure you use your Hamachi IP rather than your computer's one
- Scratch sometimes gives you an incorrect IP; find out your IP through other means
- Make sure you are connecting over a LAN network rather than over the Internet (unless you have properly configured your router)
- Make sure that the variables and broadcasts are called exactly the same (it's case-sensitive) in each project
Internals of Mesh
Mesh, in it's 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, you 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.