(Adding interwikis.)
(Automated edit: fixed 1 style guideline)
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{obsolete feature}}
 
{{obsolete feature}}
 
{{External Programs}}
 
{{External Programs}}
'''Mesh''' is a method of having multiple [[Scratch]] [[project]]s interact, even if they are on different computers. Mesh allows projects to share [[variable]]s and [[broadcast]]s, 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.
+
'''Mesh''' was a feature in [[Scratch 1.4]] allowing users to interact over a computer network. Mesh allows projects to share [[variable]]s and [[broadcast]]s, 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==
 
==How to get Mesh==
There are three ways to access Mesh in Scratch 1.4:
+
There were three ways to access Mesh in Scratch 1.4:
  
===Mesh by Beta 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 [[Scratcher]]s 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.
+
The early beta version of Scratch 1.4 had Mesh enabled. This version was shared at the first formal [[Scratch Day]]. Only a few [[Scratcher]]s were able to use this version. Mesh was disabled in the public release candidate of June of 2009.{{cite post|johnadmin|7/6/2009|the experimental "mesh" feature was removed.|[[ar-post:131585]]}}
  
An [[Smalltalk#IMAGE File|IMAGE File]] of this build can be downloaded [https://dl.dropbox.com/u/42774013/Scratch/IMAGE%20files/1.4beta.image here].
+
An [[Smalltalk#Images|image file]] of this build can be downloaded [https://web.archive.org/web/20150528151524/https://37d5d120c282af065cc07aa80787bbf94abf48ab.googledrive.com/host/0Bwg2KFU5SrIodjNSSjByeEh5dkk/0.x-1.x%20(IMAGE%20only)/Scratch%201.4%20beta.image here].
  
===Mesh by External Application===
+
===Using a Scratch Mod===
Many [[Scratch Modification|Scratch modifications]] come with Mesh already included, without having to alter anything.
+
Many [[Scratch Modification|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 [http://www.escratch.org/Scratch_1.4_Mesh'd.zip here].{{dead link}}
One mod intended solely for the enabling of Mesh is available for download [http://www.escratch.org/Scratch_1.4_Mesh'd.zip here].
 
  
[[Snap! (Programming Language)|Snap!]] and [[Panther (Scratch Modification)|Panther]] also come with Mesh pre-enabled; the latter has many [[blocks]] to use mesh.
+
[[Snap! (programming language)|BYOB 3]] and [[Panther (Scratch modification)|Panther]] also come with Mesh pre-enabled; the latter has many [[blocks]] to use Mesh.
  
===Mesh by Modification of Scratch===
+
===Modifying Scratch===
[[File:Mesh system browser.png|thumb|400px|What the System Browser should look like after editing it to activate Mesh.]]
+
[[File:Mesh system browser.png|thumb|400px|What the system browser should look like after editing it to activate Mesh.]]
This requires editing of Scratch's [[System Browser]].
+
This requires the use of the [[System Browser|system browser]].
  
 
# [[Shift-Click-R|Shift-click the R]] in the Scratch logo.
 
# [[Shift-Click-R|Shift-click the R]] in the Scratch logo.
# Select ''turn fill screen off''.
+
# 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...''.
+
# A grey space will appear arround Scratch. Click on it and select "open…" followed by "browser".
# Select 'browser''.
+
# The system browser will appear. Select "Scratch-UI-Panes", followed by "ScratchFrameMorph", "menu/button actions", and "addServerCommandsTo:".
# The System Browser will appear. Select ''Scratch-UI-Panes'' - ''ScratchFrameMorph'' - ''menu/button actions'' - ''addServerCommandsTo:''.
+
# The code of this method will appear below. Find <code>t2 ← true</code> and change it to <code>t2 ← false</code>.
# Change the "t2 ← true" text in the code 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".
# Right-click on the System Browser and select ''accept''. (If on Mac or Linux, then hold the Control key and then click).
+
# Enter your initials and click "accept".
# Enter in initials and click ''accept''.
+
# Close the system browser.
# Close the System Browser.
+
# Shift-click the R again and select "turn fill screen on".
# 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 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 not wanted anymore, the steps to enable Mesh can be reverted to remove it.
+
* If Mesh has been saved but is no longer wanted, repeat the steps but change <code>false</code> back to <code>true</code>.
* To get the ← symbol, press _ ( [Shift] + [-] ).
+
* To get the ← symbol, press _ ({{kp|Shift|-}}).
  
==How to Host and Join Mesh sessions==
+
==How to Host and Join Mesh Sessions==
 +
[[File:Host Mesh and Join Mesh.png|frame|Shift-clicking Share with Mesh enabled allows hosting and joining Mesh sessions.]]
 +
Once Mesh has been enabled, Shift-clicking Share in the menu bar will reveal two new items: Host Mesh and Join Mesh.
  
[[File:Host Mesh and Join Mesh.png|frame|Shift-clicking the Share button with Mesh enabled allows hosting and joining Mesh sessions.]]
+
* ''Host Mesh'' begins a Mesh session and shows the user's local [[IP Address|IP address]]. (This address is useful only for connecting over a local area network.)
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''.
+
* ''Join Mesh'' joins a Mesh session given an IP address.
  
* ''Host Mesh'' begins a Mesh session.
+
If the IP address of the computer has been forgotten, Share can be Shift-clicked and the item ''Show IP address'' selected.
* ''Join Mesh'' joins a Mesh session.
 
  
To host Mesh:
+
A great number of Scratch processes can be connected to a single Mesh session.
  
# Select ''Host Mesh''.
+
===Connecting Over the Internet===
# 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).
+
Normally, Mesh only works over a LAN (local area network), but it can be used over the internet by [[wikipedia:Port forwarding|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 [[wikipedia:LogMeIn Hamachi|Hamachi]] could also be used, but this must be installed on every participant's computer.)
  
To join a Mesh session:
+
The Scratch 1.4 beta had a built-in system to allow Mesh to be used across the Internet without external programs or configuration.{{cn|date=June 2019}}
  
# Select ''Join Mesh''.
+
==How to Program with Mesh==
# Enter in the IP address of the computer that is hosting the Mesh session.
+
During a 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.
+
* Broadcasts are received on all Scratch processes.
 +
* The [[Variable#Global Variables|for-all-sprites]] variables of each Scratch process can be read by the others.
  
A Mesh session can contain unlimited Scratch programs.
+
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.
===Connecting Over the Internet===
 
{{External Programs}}
 
Normally, Mesh only works over a LAN (Local Area Network); however, certain programs (such as [https://secure.logmein.com/products/hamachi2/ 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 [[wikipedia:Port forwarding|port-forwarding on Wikipedia]] or search for "port-forwarding" on the Internet. This can also be done with a port-forwarding program such as [http://grappl.io/ grappl].
+
The {{b|() 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:
  
The beta of 1.4 had a built-in system to allow Mesh to be used across the Internet without external programs or configuration.
+
<scratchblocks version="2.0">
 +
when flag clicked
 +
ask [What is my name?] and wait
 +
set [name v] to (answer)
 +
broadcast [greet v]
 +
</scratchblocks>
  
==How to Program With Mesh's Features==
+
and this in another:
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.
+
<scratchblocks version="2.0">
* Each Scratch program's variables are available for use on the others.
+
when I receive [greet v]
 +
say (join [Hello, ] ([name v] sensor value)) for (2) secs
 +
</scratchblocks>
  
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.
+
{{b|Broadcast () and Wait}} does not wait for scripts in other Scratch processes.
  
To use variables that are from a different Scratch program, the [[() Sensor Value (block)|() 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===
 
===Sending and Receiving Lists===
To send a [[list]] over Mesh, use this to transmit:
+
To share a [[list]] with Mesh, one can use broadcasts instead of {{b|Add () to ()}}, {{b|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:
<scratchblocks>
+
 
 +
<scratchblocks version="2.0">
 
when I receive [send list v]
 
when I receive [send list v]
 
set [# v] to [1]
 
set [# v] to [1]
repeat (length of [list to send v])
+
set [result v] to []
set [list v] to (join (list) (join (|) (item (#) of [list to send v]))
+
repeat (length of [list v])
change (#) by (1)
+
    set [result v] to (join (join (result) (item (#) of [list v])) [,])
 +
    change [# v] by (1)
 
end
 
end
 
broadcast [list is ready v]
 
broadcast [list is ready v]
 
</scratchblocks>
 
</scratchblocks>
To receive a [[list]], use this:
+
 
<scratchblocks>
+
and the following in the receiving project:
 +
 
 +
<scratchblocks version="2.0">
 
when I receive [list is ready v]
 
when I receive [list is ready v]
 +
delete (all v) of [list v]
 
set [# v] to [1]
 
set [# v] to [1]
repeat (length of ([list v] sensor value))
+
set [item v] to []
if <(letter (#) of ([list v] sensor value)) = []>:: control
+
repeat (length of ([result v] sensor value))
add [] to [List v]
+
    if <(letter (#) of ([result v] sensor value)) = [,]> :: control
else
+
        add (item) to [list v]
replace item (last v) of [List v] with (join (item (last v) of [List v]) (letter (#) of ([list v] sensor value))
+
        set [item v] to []
 +
    else
 +
        set [item v] to (join (item) (letter (#) of ([result v] sensor value)))
 +
    end
 +
    change [# v] by (1)
 +
end
 
</scratchblocks>
 
</scratchblocks>
 +
 +
(This works as long as none of the items contain commas.)
  
 
==Troubleshooting==
 
==Troubleshooting==
A lot of things can go wrong when activating and using Mesh, so here's a few things to check:
+
A lot of things can go wrong when enabling 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 <code>false</code> in the system browser.
* Make sure there is a period (.) after 'false' in the System Browser
+
* If changes made in the system browser were not saved, Mesh will no longer work when Scratch is closed.
* If changes to the System Browser were not saved, next time Scratch is opened, Mesh does not work anymore
+
* If one would like to use Mesh over the internet:
* If a program such as Hamachi is installed, make sure the Hamachi IP is used rather than the computer's IP
+
** Make sure port 42001 has been forwarded.
* Scratch sometimes gives an incorrect IP; find out the correct IP through other means
+
** Make sure to use the host's internet address and not its local IP address.
* Make sure connection is happening over a LAN network rather than over the Internet (unless the router has been properly configured)
+
* If one is using a program such as Hamachi, make sure the Hamachi IP address is used rather than the computer's IP address.
* Make sure that the variables and broadcasts are called exactly the same (it's case-sensitive) in each project
 
  
 
==Internals of Mesh==
 
==Internals of Mesh==
Mesh, in its rawest form, is simply [[Remote Sensor Connections|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.
+
Mesh is based upon [[Remote Sensor Connections|remote sensor connections]]; there is effectively no difference between hosting Mesh and enabling remote sensor connections.
  
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.
+
Mesh need not be hosted by Scratch; ''FireMMO'' is an example of remote sensor connections used for multiplayer servers.
  
 
==See Also==
 
==See Also==
* [[List of Scratch Modifications]] {{-}} most of these have Mesh enabled.
+
* [[Cloud Data]]
* [[Remote Sensors Protocol]] {{-}} Mesh is based on this protocol
+
* [[List of Scratch Modifications]]
* [[Cloud Data]] {{-}} Like Mesh, this allows sharing of variables between users' viewers as they view that same project
+
* [[Remote Sensors Protocol]]
  
== External Links ==
+
==External Links==
 
* [[ar-topic:32046|Mesh - how to get it, use it, and program with its features]]
 
* [[ar-topic:32046|Mesh - how to get it, use it, and program with its features]]
* [http://scratch.mit.edu/projects/martianshark/713175 Mesh Tutorial Project]
+
* [[projects:713175|Mesh Tutorial Project]]
* [http://scratch.mit.edu/scratch_1.4 Scratch 1.4 Installation Page]
+
* [[scratch:scratch_1.4|Scratch 1.4 Installation Page]]
 +
 
 +
==References==
 +
<references />
  
 
[[Category:Scratch Program]]
 
[[Category:Scratch Program]]

Latest revision as of 09:28, 10 February 2021

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.
SandCastleIcon.png 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.[1]

An image file of this build can be downloaded here.

Using a Scratch Mod

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.[dead link]

BYOB 3 and Panther also come with Mesh pre-enabled; the latter has many blocks to use Mesh.

Modifying Scratch

What the system browser should look like after editing it to activate Mesh.

This requires the use of the system browser.

  1. Shift-click the R in the Scratch logo.
  2. Select "turn fill screen off".
  3. A grey space will appear arround Scratch. Click on it and select "open…" followed by "browser".
  4. The system browser will appear. Select "Scratch-UI-Panes", followed by "ScratchFrameMorph", "menu/button actions", and "addServerCommandsTo:".
  5. The code of this method will appear below. Find t2 ← true and change it to t2 ← false.
  6. Right-click (if you are using Microsoft Windows) or hold down Control and click (otherwise) on the system browser and select "accept".
  7. Enter your initials and click "accept".
  8. Close the system browser.
  9. 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 false back to true.
  • To get the ← symbol, press _ (⇧ Shift+-).

How to Host and Join Mesh Sessions

Shift-clicking Share with Mesh enabled allows hosting and joining 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.[citation needed]

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)) 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 [1]
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 [1]
set [item v] to []
repeat (length of ([result v] sensor value))
    if <(letter (#) of ([result v] sensor value)) = [,]> :: control
        add (item) to [list v]
        set [item v] to []
    else
        set [item v] to (join (item) (letter (#) of ([result v] sensor value)))
    end
    change [# v] by (1)
end

(This works as long as none of the items contain commas.)

Troubleshooting

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 false in 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.

See Also

External Links

References

  1. johnadmin. (7/6/2009). "the experimental "mesh" feature was removed." ar-post:131585
Cookies help us deliver our services. By using our services, you agree to our use of cookies.