I right click on these blocks and I get remote sensor connections. When I click it, I don't understand what it does.
P.S. It does not make it so the sensor board is connected not by USB cable.
[blocks]<forever if>
<else>
<end>[/blocks]
Last edited by zorket (2011-06-22 10:43:19)
Offline
It's mesh.
Offline
Billybob-Mario wrote:
It's mesh.
No, it's a way for external programs to connect with Scratch.
Offline
Remote Sensors is a way to connect things, like Python and Scratch. You can make multiplayer with Remote Connections.
http://scratchconnections.wik.is/ <- You can learn more about it there.
Offline
If you enable remote sensor connections, you canmake Scratch comunicate with other programs, such as Python.
Here is a Python(v2.6) program that connects with Scratch:
# Scratch client test program
# Demonstrates the Scratch Network Connection Functionality
from array import array
import socket
import time
HOST = '127.0.0.1' # IP address of the remote host (in this case, the local machine)
# to connect to Scratch on a different computer, just put in its IP address
PORT = 42001 # The same port as used by the server
# sendScratchCommand(cmd)
# this function packages a message according the Scratch Networking Protocol
# and then sends it off
def sendScratchCommand(cmd):
n = len(cmd)
a = array('c')
a.append(chr((n >> 24) & 0xFF))
a.append(chr((n >> 16) & 0xFF))
a.append(chr((n >> 8) & 0xFF))
a.append(chr(n & 0xFF))
scratchSock.send(a.tostring() + cmd)
# Make a connection to Scratch
print("connecting...")
scratchSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
scratchSock.connect((HOST, PORT))
print("connected!")
# Emulate the green flag being clicked (optional)
sendScratchCommand('broadcast "scratch-startclicked"')
print("manually starting up Scratch")
# Display broadcasts and global var changes
while 1:
data = scratchSock.recv(1024)
if not data: break
print(data)
scratchSock.close()
Don't ask me why I decided to spend all that time getting the coloring to look like real Python. :P
Last edited by rubiks_cube_guy238 (2010-08-15 21:28:33)
Offline
if you turn is on then you can communicate with other stuff like python
Offline