Scratch 1.4 on raspberry pi allows to connect with other scratch instances on other computers.
This is an experimental feature. This feature is not available in scratch1.4 for linux or windows, not in scratch2.
With this feature multiple scratch 1.4 can share events and (global) variables.
As this feature is experimental, there are some constraints and problems especially when scratchClient is used also.
ScratchClient has a feature to interconnect computers too. This uses scratchCommunicationServer.py which allows filtering and segmentation of larger networks.
Enable Mesh Session
Scratch 1.4 has a ‚Share‘ menu point. This menu has different content when ‚shift‘ is pressed before the mouse click.
Enable mesh session by ‘shift’ and press ‘Share’-menu.
‚Host Mesh‘ means that this scratch is opening the mesh. It ‚hosts‘ the mesh. In other words this scratch becomes a server.
‚Join Mesh‘ means that the scratch connects to a mesh network another computer has opened before. In other words this is a ‚client‘. The client needs to know the IP address of the server.
When ‚Host Mesh‘ is executed, the IP address of the computer is displayed.
There is a menu entry on a ‚host‘ computer which allows to display this again:
enable ‘host mesh’ session
display ip address, e.g. 192.168.2.200
join mesh session
enter ip address of computer A
Broadcast events of one computer are sent to computer B also.
Global variables of one computer are visible on ‘sensing’ tab, sensor values on the other computer.
The variable (here ‚a‘) can only be changed on the one computer where it is is created. Sensor value can‘t be changed.
- Scope: Variables should be ‘for this sprite only’ whenever possible. Use ‘for all sprites’ only if needed or when these should be transferred to other computer.
- Naming: Variables and events which need to be transferred should get a special name which includes the sending computer name. So if sending computer is ‘box07’ and variable is ‘a’, then name is ‘box07.name’.
The client side does not store it’s state in the project file. ‘join mesh’ needs to be done each time the project is opened.
Topology with scratchClient
scratchClient connection works on server side only. On client side, when sensor network is enabled then the mesh connection is stopped and thus scratchClient can’t be used.
The ‚enable remote sensor connections‘ command is not needed when ‚Host Mesh‘ is used.
ScratchClient issues a warning about an unknown command, but this does not stop anything.
The involved computers need to be connected to a network.
When computers are configured to use fixed IP-Addresses, then for a two computer network a crossover-ethernet patch cable can be used.
Network connection on a raspberry pi.
The color of a cable does not imply whether a normal connection or crossover connection type cable is used.