This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-07-12 18:40:24

redware
Scratcher
Registered: 2007-05-21
Posts: 92

Scratch Connections - Conventions ?

I have started playing around to make a remote sensor connections server program in C# so you can connect multiple scratch clients in a classroom (or around the world). There are some great examples on the connections wiki including SNYFF (an Adobe Air client) and the unpublished chapter Scratchable Java which explains a lot of things. See http://scratchconnections.wik.is/Getting_Started

It took me a while to work out how to create your own sensor variables from an outside program (just send a sensor-update command which will create your sensor inside scratch). So far, I have information on the following three types of message to send to Scracth:

sensor-update "fred" 0.1
broadcast "fred"
broadcast "Scratch-StartClicked"

You receive broadcasts and changes to the values of sensors and global variables but can only send back sensors and broadcasts (not variables). There may be more special scratch broadcasts but I can only find the Scratch-StartClicked to start off the application. Can anyone point me to a source for more info ?

There are some great ideas on conventions by Chalkmarrow in the Snyff documentation which I think I will adopt too particularly using a broadcast of the form >broadcast to indicate you want the message broadcast to connected scratch users (and rename to <broadcast on the incoming message). He also prefixes with @ if the message is local and not to be broadcast.

Chalkmarrow has thought things out well on his catenary connection to a sensor board which uses a ^ prefix to broadcast messages to the sensor board (reset and so on). He also has special broadcasts for recignising a connection ... snyfsez hello and snyfsez friendconnected.

I hope some of you will use this thread to suggest more possible conventions (and fill out the list of commands) to aid people writing server connections for Scratch... I will post up my server in a couple of weeks when it is ready.

Last edited by redware (2009-07-12 18:41:39)

Offline

 

#2 2009-07-13 01:18:10

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Scratch Connections - Conventions ?

Cool. Great idea. Note that Scratch 1.4 dispenses with the "Scratch-" prefix in variable names. And I believe the StartClicked has gone away. Also, one thing that the regular expressions have to accommodate multiple variable changes in one line -- e.g., sensor-update "x" 4 "y" 6

I agree that the conventions for communicating between multiple players is the difficult part.

Offline

 

#3 2009-07-13 01:50:23

redware
Scratcher
Registered: 2007-05-21
Posts: 92

Re: Scratch Connections - Conventions ?

Thanks for the reply Chalkmarrow (and for putting some great ideas into Snyff). I was thinking overnight about conventions for connecting and building multi-player games.

Say you want to build a four player game - you might have sensors for the x and y position for each of the four player sprites and you might call these xpos0, xpos1, xpos2, xpos3, ypos0 and so on (0 is you and 1,2,3 the other players). You need to use sensors because you cannot set variables the other player's scratch (I think).

Maybe we call these sensors xpos#1, xpos#2, xpos#3 inside the scratch program and the server keeps track of which player is which on the system automatically translating the value of xpos#0 to the required player version for the other players.

Not sure this makes sense - but if you are player 3 then your sensor xpos#0 is translated to xpos#3 for the other players. That way one copy of scratch will run the multiplayer game.

I am not sure if you can set sensors values within Scratch so this would work with a global variable called xpos#0 (or similar) which would be manipulated by the server and translated to a sensor variable xpos#3 for the other players.

Maybe what I am saying here (in one line) is that a global variable with a # character is translated by the server to a sensor with the player number replacing the # character.

An idea to be refined methinks....

Last edited by redware (2009-07-13 01:52:19)

Offline

 

#4 2009-07-13 17:04:10

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Scratch Connections - Conventions ?

Yep. You're struggling with the same things I am. Instead of a postfix (#1), what I'm doing is adding a prefix based on the "friend number," but those prefixes can be turned on and off. I'm hoping to make it sufficiently configurable that kids can use it in lots of different ways.

Offline

 

#5 2009-07-16 02:46:58

redware
Scratcher
Registered: 2007-05-21
Posts: 92

Re: Scratch Connections - Conventions ?

It seems that global variables are one way only (is there a variable-update command?) and you cannot update sensors within an application. Is there scope therefore for a global variiable to have a prefix (say &) that will automatically cause the server to change it to a sensor update ? Or is there a way to set the global variable from the server in Scratch ?

Last edited by redware (2009-07-16 02:47:22)

Offline

 

#6 2009-07-16 02:48:02

redware
Scratcher
Registered: 2007-05-21
Posts: 92

Re: Scratch Connections - Conventions ?

I am thinking of other standards to suggest a name for the game and the number of players that need to connect....

Offline

 

#7 2009-07-17 09:58:28

redware
Scratcher
Registered: 2007-05-21
Posts: 92

Re: Scratch Connections - Conventions ?

Maybe the wiki is the best place for this conversation. I have started a page there....

http://scratchconnections.wik.is/Creating_Scratch_Servers/Conventions

Offline

 

#8 2009-07-17 10:56:36

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: Scratch Connections - Conventions ?

Okay! I'll go there!

Offline

 

Board footer