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

#176 2012-05-05 13:59:47

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

tongue  So anyway I debugged it(see above post). I'll try getting on now...
edit: I shouldn't say debugged...
I'm taking the (moon) to mean that Pascal is a copy :p
(it came before C)
edit2: This next problem is for a Python pro, not an newbie like me...
Magnie  tongue

Last edited by slinger (2012-05-05 14:03:48)


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#177 2012-05-05 14:32:49

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Mmk.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#178 2012-05-05 14:55:03

Zeusking19
Scratcher
Registered: 2011-07-10
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Can i have the pass for the DT Hamachi network?

I had to wipe my pc...

Last edited by Zeusking19 (2012-05-05 14:55:16)


http://i49.tinypic.com/2w7e1jm.pnghttp://dragcave.net/image/eFGFz.gifhttp://dragcave.net/image/9hE5q.gif

Offline

 

#179 2012-05-05 14:56:28

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Zeusking19 wrote:

Can i have the pass for the DT Hamachi network?

I had to wipe my pc...

I dunno what it is.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#180 2012-05-05 17:49:15

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

Re: DragonThunder (formerly Virtual Ground)

Code:

# Scratch Mirror
# Version 1.5.0
# Originally by: Magnie. Modified by bobbybee for use in FireMMO

import socket # Network base
import time # For delaying purposes mostly.
import threading # So it can send and receive at the same time anytime.
import array

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CHOST is the IP Scratch is running on, if you are running it    #
# on this computer, then the IP is 127.0.0.1                      #
# Theoretically you could run this Mirror on another computer.    #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CPOST is the port Scratch is listening on, the default is       #
# 42001. Usually this is only change by a Scratcher who knows a   #
# about Squeak and networking with sockets.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
CHOST = '127.0.0.1'
CPORT = 42001

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SHOST is the IP the server is running on.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SPORT is the port that the server is using. 42002 is the        #
# unofficial port for Scratch Servers. The host will need to make #
# sure to port-forward the port so people can connect from the    #
# internet.                                                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
SHOST = '96.127.188.39'
SPORT = 8089

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# Some extra settings that are more for advanced users are below. #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

# Time between checking the threads for broken ones.
THREADCHECK = 5



class Client(threading.Thread): # This class listens for messages sent from Scratch and sends it to the Server.
    def parse_message(self, message):
        if message:
            sensors = {}
            broadcasts = []

            commands = []
            i = 0
            while True:
                length = ord(message[i]) + ord(message[i+1]) + ord(message[i+2]) + ord(message[i+3])
            
                command = message[i + 4:i + length + 4]
                commands.append(command)
                if (i + length + 4) < len(message):
                    i = (i+4) + length
                else:
                    del command
                    break
            
                for command in commands:
                    if command[0] == 'b':
                        command = command.split('"')
                        command.pop(0)
                        broadcasts.append(command[0])
                
                    elif command[0] == 's':
                        command = command.split('"')
                        command.pop(0)
                        try:
                            command.remove(' ')
                        except ValueError:
                            pass
                    sensors[command[0]] = command[1]
        
                return dict([('sensor-update', sensors), ('broadcast', broadcasts)])
        else: 
            return None
    def sendScratchCommand(self, 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))
        server.sock.send(a.tostring() + cmd)
    
    def __init__(self, CHOST, CPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch...")
        self.sock.connect((CHOST, CPORT)) # Connect to Scratch
        print("Connected to Scratch!")
        
    def run(self):
        global running
        print "Listening for Scratch messages."
        while running:
            data = self.sock.recv(1024) # Wait for something to be sent to the mirror
            
            data = self.parse_message(data)
            for sensor in data['sensor-update']:
                if sensor == "packet":
                    self.send(data['sensor-update'][sensor])

    
    def send(self, message):
        server.sock.send(message) # Send the data to the server.

class Server(threading.Thread): # This class listens for messages from the Server and sends it to Scratch.
    def sendScratchCommand(self, cmd):
        n = len(cmd)
        a = []
        a.append(chr((n >> 24) & 0xFF))
        a.append(chr((n >> 16) & 0xFF))
        a.append(chr((n >>  8) & 0xFF))
        a.append(chr(n & 0xFF))
        scratch.sock.send(''.join(a) + cmd)
    def __init__(self, SHOST, SPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch Server...")
        self.sock.connect((SHOST, SPORT)) # Connect to the Server.
        print("Connected to Server!")
        
    def run(self):   
        global running
        print "Listening for Server messages."
        while running:    
            data = self.sock.recv(1024) # Listens for messages sent from the Server.
        print(data);
        self.sendScratchCommand("sensor-update packet \""+data+"\"");
        self.sendScratchCommand("broadcast dataready")
    
    def send(self, message):
        scratch.sock.send(message) # Sends messages to Scratch.

running = 1
scratch = Client(CHOST, CPORT) # Start up the class for Scratch
scratch.start() # This starts the 'run' function.

server = Server(SHOST, SPORT) # Start up the class for Server
server.start() # This starts the 'run' function on the class as well.

while running:
    time.sleep(THREADCHECK) # The longer the wait time, the less CPU is used I think.
    try: # Check if the either thread died ( or exists anymore ).
        if scratch:
            pass
    except Exception, e:
        print e
        running = 0

In the future, could you post the errors?

Offline

 

#181 2012-05-05 19:50:15

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Magnie wrote:

Code:

# Scratch Mirror
# Version 1.5.0
# Originally by: Magnie. Modified by bobbybee for use in FireMMO

import socket # Network base
import time # For delaying purposes mostly.
import threading # So it can send and receive at the same time anytime.
import array

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CHOST is the IP Scratch is running on, if you are running it    #
# on this computer, then the IP is 127.0.0.1                      #
# Theoretically you could run this Mirror on another computer.    #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CPOST is the port Scratch is listening on, the default is       #
# 42001. Usually this is only change by a Scratcher who knows a   #
# about Squeak and networking with sockets.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
CHOST = '127.0.0.1'
CPORT = 42001

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SHOST is the IP the server is running on.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SPORT is the port that the server is using. 42002 is the        #
# unofficial port for Scratch Servers. The host will need to make #
# sure to port-forward the port so people can connect from the    #
# internet.                                                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
SHOST = '96.127.188.39'
SPORT = 8089

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# Some extra settings that are more for advanced users are below. #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

# Time between checking the threads for broken ones.
THREADCHECK = 5



class Client(threading.Thread): # This class listens for messages sent from Scratch and sends it to the Server.
    def parse_message(self, message):
        if message:
            sensors = {}
            broadcasts = []

            commands = []
            i = 0
            while True:
                length = ord(message[i]) + ord(message[i+1]) + ord(message[i+2]) + ord(message[i+3])
            
                command = message[i + 4:i + length + 4]
                commands.append(command)
                if (i + length + 4) < len(message):
                    i = (i+4) + length
                else:
                    del command
                    break
            
                for command in commands:
                    if command[0] == 'b':
                        command = command.split('"')
                        command.pop(0)
                        broadcasts.append(command[0])
                
                    elif command[0] == 's':
                        command = command.split('"')
                        command.pop(0)
                        try:
                            command.remove(' ')
                        except ValueError:
                            pass
                    sensors[command[0]] = command[1]
        
                return dict([('sensor-update', sensors), ('broadcast', broadcasts)])
        else: 
            return None
    def sendScratchCommand(self, 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))
        server.sock.send(a.tostring() + cmd)
    
    def __init__(self, CHOST, CPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch...")
        self.sock.connect((CHOST, CPORT)) # Connect to Scratch
        print("Connected to Scratch!")
        
    def run(self):
        global running
        print "Listening for Scratch messages."
        while running:
            data = self.sock.recv(1024) # Wait for something to be sent to the mirror
            
            data = self.parse_message(data)
            for sensor in data['sensor-update']:
                if sensor == "packet":
                    self.send(data['sensor-update'][sensor])

    
    def send(self, message):
        server.sock.send(message) # Send the data to the server.

class Server(threading.Thread): # This class listens for messages from the Server and sends it to Scratch.
    def sendScratchCommand(self, cmd):
        n = len(cmd)
        a = []
        a.append(chr((n >> 24) & 0xFF))
        a.append(chr((n >> 16) & 0xFF))
        a.append(chr((n >>  8) & 0xFF))
        a.append(chr(n & 0xFF))
        scratch.sock.send(''.join(a) + cmd)
    def __init__(self, SHOST, SPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch Server...")
        self.sock.connect((SHOST, SPORT)) # Connect to the Server.
        print("Connected to Server!")
        
    def run(self):   
        global running
        print "Listening for Server messages."
        while running:    
            data = self.sock.recv(1024) # Listens for messages sent from the Server.
        print(data);
        self.sendScratchCommand("sensor-update packet \""+data+"\"");
        self.sendScratchCommand("broadcast dataready")
    
    def send(self, message):
        scratch.sock.send(message) # Sends messages to Scratch.

running = 1
scratch = Client(CHOST, CPORT) # Start up the class for Scratch
scratch.start() # This starts the 'run' function.

server = Server(SHOST, SPORT) # Start up the class for Server
server.start() # This starts the 'run' function on the class as well.

while running:
    time.sleep(THREADCHECK) # The longer the wait time, the less CPU is used I think.
    try: # Check if the either thread died ( or exists anymore ).
        if scratch:
            pass
    except Exception, e:
        print e
        running = 0

In the future, could you post the errors?

Why are you quoting me? I didn't post buggy code. (hopefully)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#182 2012-05-05 19:58:49

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

Re: DragonThunder (formerly Virtual Ground)

bobbybee wrote:

Magnie wrote:

Code:

# Scratch Mirror
# Version 1.5.0
# Originally by: Magnie. Modified by bobbybee for use in FireMMO

import socket # Network base
import time # For delaying purposes mostly.
import threading # So it can send and receive at the same time anytime.
import array

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CHOST is the IP Scratch is running on, if you are running it    #
# on this computer, then the IP is 127.0.0.1                      #
# Theoretically you could run this Mirror on another computer.    #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CPOST is the port Scratch is listening on, the default is       #
# 42001. Usually this is only change by a Scratcher who knows a   #
# about Squeak and networking with sockets.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
CHOST = '127.0.0.1'
CPORT = 42001

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SHOST is the IP the server is running on.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SPORT is the port that the server is using. 42002 is the        #
# unofficial port for Scratch Servers. The host will need to make #
# sure to port-forward the port so people can connect from the    #
# internet.                                                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
SHOST = '96.127.188.39'
SPORT = 8089

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# Some extra settings that are more for advanced users are below. #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

# Time between checking the threads for broken ones.
THREADCHECK = 5



class Client(threading.Thread): # This class listens for messages sent from Scratch and sends it to the Server.
    def parse_message(self, message):
        if message:
            sensors = {}
            broadcasts = []

            commands = []
            i = 0
            while True:
                length = ord(message[i]) + ord(message[i+1]) + ord(message[i+2]) + ord(message[i+3])
            
                command = message[i + 4:i + length + 4]
                commands.append(command)
                if (i + length + 4) < len(message):
                    i = (i+4) + length
                else:
                    del command
                    break
            
                for command in commands:
                    if command[0] == 'b':
                        command = command.split('"')
                        command.pop(0)
                        broadcasts.append(command[0])
                
                    elif command[0] == 's':
                        command = command.split('"')
                        command.pop(0)
                        try:
                            command.remove(' ')
                        except ValueError:
                            pass
                    sensors[command[0]] = command[1]
        
                return dict([('sensor-update', sensors), ('broadcast', broadcasts)])
        else: 
            return None
    def sendScratchCommand(self, 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))
        server.sock.send(a.tostring() + cmd)
    
    def __init__(self, CHOST, CPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch...")
        self.sock.connect((CHOST, CPORT)) # Connect to Scratch
        print("Connected to Scratch!")
        
    def run(self):
        global running
        print "Listening for Scratch messages."
        while running:
            data = self.sock.recv(1024) # Wait for something to be sent to the mirror
            
            data = self.parse_message(data)
            for sensor in data['sensor-update']:
                if sensor == "packet":
                    self.send(data['sensor-update'][sensor])

    
    def send(self, message):
        server.sock.send(message) # Send the data to the server.

class Server(threading.Thread): # This class listens for messages from the Server and sends it to Scratch.
    def sendScratchCommand(self, cmd):
        n = len(cmd)
        a = []
        a.append(chr((n >> 24) & 0xFF))
        a.append(chr((n >> 16) & 0xFF))
        a.append(chr((n >>  8) & 0xFF))
        a.append(chr(n & 0xFF))
        scratch.sock.send(''.join(a) + cmd)
    def __init__(self, SHOST, SPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch Server...")
        self.sock.connect((SHOST, SPORT)) # Connect to the Server.
        print("Connected to Server!")
        
    def run(self):   
        global running
        print "Listening for Server messages."
        while running:    
            data = self.sock.recv(1024) # Listens for messages sent from the Server.
        print(data);
        self.sendScratchCommand("sensor-update packet \""+data+"\"");
        self.sendScratchCommand("broadcast dataready")
    
    def send(self, message):
        scratch.sock.send(message) # Sends messages to Scratch.

running = 1
scratch = Client(CHOST, CPORT) # Start up the class for Scratch
scratch.start() # This starts the 'run' function.

server = Server(SHOST, SPORT) # Start up the class for Server
server.start() # This starts the 'run' function on the class as well.

while running:
    time.sleep(THREADCHECK) # The longer the wait time, the less CPU is used I think.
    try: # Check if the either thread died ( or exists anymore ).
        if scratch:
            pass
    except Exception, e:
        print e
        running = 0

In the future, could you post the errors?

Why are you quoting me? I didn't post buggy code. (hopefully)

It's the fixed version of the mirror you posted on the page before this. It's not the same. The other one had many indentation errors.

Last edited by Magnie (2012-05-05 20:00:18)

Offline

 

#183 2012-05-05 20:14:27

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Makes more sense. Hey, I never say I use good code.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#184 2012-05-06 04:59:41

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Magnie wrote:

Code:

# Scratch Mirror
# Version 1.5.0
# Originally by: Magnie. Modified by bobbybee for use in FireMMO

import socket # Network base
import time # For delaying purposes mostly.
import threading # So it can send and receive at the same time anytime.
import array

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CHOST is the IP Scratch is running on, if you are running it    #
# on this computer, then the IP is 127.0.0.1                      #
# Theoretically you could run this Mirror on another computer.    #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CPOST is the port Scratch is listening on, the default is       #
# 42001. Usually this is only change by a Scratcher who knows a   #
# about Squeak and networking with sockets.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
CHOST = '127.0.0.1'
CPORT = 42001

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SHOST is the IP the server is running on.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SPORT is the port that the server is using. 42002 is the        #
# unofficial port for Scratch Servers. The host will need to make #
# sure to port-forward the port so people can connect from the    #
# internet.                                                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
SHOST = '96.127.188.39'
SPORT = 8089

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# Some extra settings that are more for advanced users are below. #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

# Time between checking the threads for broken ones.
THREADCHECK = 5



class Client(threading.Thread): # This class listens for messages sent from Scratch and sends it to the Server.
    def parse_message(self, message):
        if message:
            sensors = {}
            broadcasts = []

            commands = []
            i = 0
            while True:
                length = ord(message[i]) + ord(message[i+1]) + ord(message[i+2]) + ord(message[i+3])
            
                command = message[i + 4:i + length + 4]
                commands.append(command)
                if (i + length + 4) < len(message):
                    i = (i+4) + length
                else:
                    del command
                    break
            
                for command in commands:
                    if command[0] == 'b':
                        command = command.split('"')
                        command.pop(0)
                        broadcasts.append(command[0])
                
                    elif command[0] == 's':
                        command = command.split('"')
                        command.pop(0)
                        try:
                            command.remove(' ')
                        except ValueError:
                            pass
                    sensors[command[0]] = command[1]
        
                return dict([('sensor-update', sensors), ('broadcast', broadcasts)])
        else: 
            return None
    def sendScratchCommand(self, 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))
        server.sock.send(a.tostring() + cmd)
    
    def __init__(self, CHOST, CPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch...")
        self.sock.connect((CHOST, CPORT)) # Connect to Scratch
        print("Connected to Scratch!")
        
    def run(self):
        global running
        print "Listening for Scratch messages."
        while running:
            data = self.sock.recv(1024) # Wait for something to be sent to the mirror
            
            data = self.parse_message(data)
            for sensor in data['sensor-update']:
                if sensor == "packet":
                    self.send(data['sensor-update'][sensor])

    
    def send(self, message):
        server.sock.send(message) # Send the data to the server.

class Server(threading.Thread): # This class listens for messages from the Server and sends it to Scratch.
    def sendScratchCommand(self, cmd):
        n = len(cmd)
        a = []
        a.append(chr((n >> 24) & 0xFF))
        a.append(chr((n >> 16) & 0xFF))
        a.append(chr((n >>  8) & 0xFF))
        a.append(chr(n & 0xFF))
        scratch.sock.send(''.join(a) + cmd)
    def __init__(self, SHOST, SPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch Server...")
        self.sock.connect((SHOST, SPORT)) # Connect to the Server.
        print("Connected to Server!")
        
    def run(self):   
        global running
        print "Listening for Server messages."
        while running:    
            data = self.sock.recv(1024) # Listens for messages sent from the Server.
        print(data);
        self.sendScratchCommand("sensor-update packet \""+data+"\"");
        self.sendScratchCommand("broadcast dataready")
    
    def send(self, message):
        scratch.sock.send(message) # Sends messages to Scratch.

running = 1
scratch = Client(CHOST, CPORT) # Start up the class for Scratch
scratch.start() # This starts the 'run' function.

server = Server(SHOST, SPORT) # Start up the class for Server
server.start() # This starts the 'run' function on the class as well.

while running:
    time.sleep(THREADCHECK) # The longer the wait time, the less CPU is used I think.
    try: # Check if the either thread died ( or exists anymore ).
        if scratch:
            pass
    except Exception, e:
        print e
        running = 0

In the future, could you post the errors?

Yeah, really sorry about that, I was kinda groggy  tongue
I'll be sure to post the errors in the future :3


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#185 2012-05-06 06:55:28

Zeusking19
Scratcher
Registered: 2011-07-10
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

I am gonna be on long-term leave for a while. I am on the spare laptop after the memory failed on my main rig.

Last edited by Zeusking19 (2012-05-06 06:55:58)


http://i49.tinypic.com/2w7e1jm.pnghttp://dragcave.net/image/eFGFz.gifhttp://dragcave.net/image/9hE5q.gif

Offline

 

#186 2012-05-06 08:22:42

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

You could buy a cheap Windows machine, over-clock it, and be just run low-memory programs. It might allow you to do some basic work.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#187 2012-05-06 17:12:28

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Woo-hoo! Version 1.1.2 is officially released (see my account. note: I will inform you when I upload it to the DragonThunder official account)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#188 2012-05-06 18:14:34

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: DragonThunder (formerly Virtual Ground)

I get the following messages (running in Terminal on Mac):


Connecting to Scratch...
Connected to Scratch!
Listening for Scratch messages.
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/Quick_access/dth2.py", line 102, in run
    for sensor in data['sensor-update']:
TypeError: 'NoneType' object is not subscriptable

Connecting to Scratch Server...
Connected to Server!
Listening for Server messages.


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#189 2012-05-06 18:26:28

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

That usually means remote sensor connections isn't enabled.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#190 2012-05-06 19:08:14

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: DragonThunder (formerly Virtual Ground)

Hmm...

It was enabled.
When it wasn't, I got this:


Connecting to Scratch...
Traceback (most recent call last):
  File "/Quick_access/dth2.py", line 139, in <module>
    scratch = Client(CHOST, CPORT) # Start up the class for Scratch
  File "/Quick_access/dth2.py", line 92, in __init__
    self.sock.connect((CHOST, CPORT)) # Connect to Scratch
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 61] Connection refused


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#191 2012-05-06 19:28:47

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Post your code on pastebin. (the source dth2.py)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#192 2012-05-07 07:15:21

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Bump


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#193 2012-05-08 10:00:00

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: DragonThunder (formerly Virtual Ground)

bobbybee wrote:

Post your code on pastebin. (the source dth2.py)

http://pastebin.com/WCxbmGNT


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#194 2012-05-08 16:07:40

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Um...try this one.

Code:

# Scratch Mirror
# Version 1.5.0
# Originally by: Magnie. Modified by bobbybee for use in FireMMO

import socket # Network base
import time # For delaying purposes mostly.
import threading # So it can send and receive at the same time anytime.
import array

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CHOST is the IP Scratch is running on, if you are running it    #
# on this computer, then the IP is 127.0.0.1                      #
# Theoretically you could run this Mirror on another computer.    #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# CPOST is the port Scratch is listening on, the default is       #
# 42001. Usually this is only change by a Scratcher who knows a   #
# about Squeak and networking with sockets.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
CHOST = '127.0.0.1'
CPORT = 42001

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SHOST is the IP the server is running on.                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# SPORT is the port that the server is using. 42002 is the        #
# unofficial port for Scratch Servers. The host will need to make #
# sure to port-forward the port so people can connect from the    #
# internet.                                                       #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
SHOST = '96.127.188.39'
SPORT = 8089

# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #
# Some extra settings that are more for advanced users are below. #
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### #

# Time between checking the threads for broken ones.
THREADCHECK = 5



class Client(threading.Thread): # This class listens for messages sent from Scratch and sends it to the Server.
    def parse_message(self, message):
        if message:
            sensors = {}
            broadcasts = []

            commands = []
            i = 0
            while True:
                length = ord(message[i]) + ord(message[i+1]) + ord(message[i+2]) + ord(message[i+3])
            
                command = message[i + 4:i + length + 4]
                commands.append(command)
                if (i + length + 4) < len(message):
                    i = (i+4) + length
                else:
                    del command
                    break
            
            for command in commands:
        print command
                if command[0] == 'b':
                    command = command.split('"')
                    command.pop(0)
                    broadcasts.append(command[0])
                
                elif command[0] == 's':
                    command = command.split('"')
                    command.pop(0)
            print(command);
                    try:
                command.remove(' ')
            except ValueError:
                     pass
                    sensors[command[0]] = command[1]
        
            return dict([('sensor-update', sensors), ('broadcast', broadcasts)])
        else: 
            return None
    def sendScratchCommand(self, 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))
        server.sock.send(a.tostring() + cmd)
    
    def __init__(self, CHOST, CPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch...")
        self.sock.connect((CHOST, CPORT)) # Connect to Scratch
        print("Connected to Scratch!")
        
    def run(self):
        global running
        print "Listening for Scratch messages."
        while running:
            data = self.sock.recv(1024) # Wait for something to be sent to the mirror
            
            data = self.parse_message(data)
            for sensor in data['sensor-update']:
                if sensor == "packet":
                    self.send(data['sensor-update'][sensor])

    
    def send(self, message):
        server.sock.send(message) # Send the data to the server.

class Server(threading.Thread): # This class listens for messages from the Server and sends it to Scratch.
    def sendScratchCommand(self, cmd):
        n = len(cmd)
        a = []
        a.append(chr((n >> 24) & 0xFF))
        a.append(chr((n >> 16) & 0xFF))
        a.append(chr((n >>  8) & 0xFF))
        a.append(chr(n & 0xFF))
        scratch.sock.send(''.join(a) + cmd)
    def __init__(self, SHOST, SPORT):
        threading.Thread.__init__(self) # Initialize it, basically just separate it from the main thread.
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Defines the type of connection ( UPD, TCP on IPv4 or IPv6 )
        print("Connecting to Scratch Server...")
        self.sock.connect((SHOST, SPORT)) # Connect to the Server.
        print("Connected to Server!")
        
    def run(self):   
        global running
        print "Listening for Server messages."
        while running:    
            data = self.sock.recv(1024) # Listens for messages sent from the Server.
        print(data);
            self.sendScratchCommand("sensor-update packet \""+data+"\"");
            self.sendScratchCommand("broadcast dataready")
    
    def send(self, message):
        scratch.sock.send(message) # Sends messages to Scratch.

running = 1
scratch = Client(CHOST, CPORT) # Start up the class for Scratch
scratch.start() # This starts the 'run' function.

server = Server(SHOST, SPORT) # Start up the class for Server
server.start() # This starts the 'run' function on the class as well.

while running:
    time.sleep(THREADCHECK) # The longer the wait time, the less CPU is used I think.
    try: # Check if the either thread died ( or exists anymore ).
        if scratch: pass
        if server: pass
    except: # If either are dead, end the program.
        running = 0
        print "Finished running."

I support the Free Software Foundation. Protect our digital rights!

Offline

 

#195 2012-05-08 19:42:27

zippynk
Scratcher
Registered: 2011-07-23
Posts: 500+

Re: DragonThunder (formerly Virtual Ground)

Hmm... now I get

File "/Quick_access/dth2.py", line 62
    print command
    ^
IndentationError: expected an indented block

Last edited by zippynk (2012-05-08 19:42:44)


https://dl.dropbox.com/u/60598636/trifocal_interlude_soundcloud_button.png

Offline

 

#196 2012-05-08 19:43:38

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

http://pastebin.com/txj2QUJ1 <--- try this


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#197 2012-05-19 11:21:45

Zeusking19
Scratcher
Registered: 2011-07-10
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

w00t!

Bobby is doing a presentation at MIT about DT for Scratch Day!


http://i49.tinypic.com/2w7e1jm.pnghttp://dragcave.net/image/eFGFz.gifhttp://dragcave.net/image/9hE5q.gif

Offline

 

#198 2012-06-02 20:07:02

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

DragonThunder Players, Team, and other users:

       Due to a security vulnerability in the DragonThunder server, a hacker successfully accessed the DragonThunder server. No known damage was done to the server, as it was patched in time, but database records may or may not have been read. Specific details of the attack will not be publicly available for security reasons, but on a per-case basis, I may be able to explain further by private messaging.

       The attack itself aside, there are many security concerns arising, such as leaked passwords and personal information. Issues in the DragonThunder server version 1.3.2 (the public DragonThunder server at the time of writing, and the server that supports DragonThunder client version 1.3.1) are prone to low or no encryption. Passwords and other information in the database (this may or may not include: username registered with, password, IP address, dragon color, others can only be discussed privately) are encrypted with MySQL's servers security, using a strong password, however, the password to the MySQL server would've been exposed to an attacker. Inside of the database, passwords are stored unencrypted as of DragonThunder server 1.3.2.

       With this additional information, you may need advice on how to protect yourself from the attack. The most important thing is to make sure your DragonThunder password is not used on other sites (else change it). If you would like a further investigation regarding your account, contact the DragonThunder team (bobbybee or Zeusking19 are the 2 members who were active during the attack) for assistance.

      Our sincere apologies for any inconvenience,
               -The DragonThunder Team


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#199 2012-06-04 09:40:20

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

Re: DragonThunder (formerly Virtual Ground)

You should always mention when passwords aren't being encrypted and always use hashes in the first place.

Offline

 

#200 2012-06-04 16:20:23

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: DragonThunder (formerly Virtual Ground)

Magnie wrote:

You should always mention when passwords aren't being encrypted and always use hashes in the first place.

...


I support the Free Software Foundation. Protect our digital rights!

Offline

 

Board footer