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

#1 2012-04-29 13:09:18

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

DragonThunder - A REAL MMO - Releasing today

DragonThunder, a REAL MMO (massively multiplayer online) game is being released today. To play:

1) Download the Scratch project at http://scratch.mit.edu/projects/DragonThunder/2473759

2) Prepping Scratch

2a) Go to sensing in Scratch (with the DragonThunder project open)

2b) Right-click the slider sensor-value box.

 ([slider v] sensor value)
2c) Click "enable remote sensor connections"

3) Download the mirror
ON WINDOWS:
http://dl.dropbox.com/u/32942793/DTMirror.zip Open the exe.

ON MAC:
3a) Make a file on your desktop. Call it mirror.py. Make it's contents:

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 = 'firechat.servequake.com'
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."

3b) Go to Applications in Finder, scroll down to Utillities, and open Terminal.app from there
3c) Type "cd Desktop; python mirror.py <enter>" (no quotes, replace <enter> with the enter/return key

4) FUN! The Guest account is:
Username: Guest
Password: DragonThunder123


Thanks to Magnie, this project would've never worked.

CREDITS:

Programming:
bobbybee
Magnie

Art:
trinary

Ideas:
coolhogs
TorbyFork234

Special Thanks to:
Magnie
Mom & Dad

Last edited by bobbybee (2012-04-29 13:19:27)


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

Offline

 

#2 2012-04-29 13:26:29

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

Re: DragonThunder - A REAL MMO - Releasing today

Awesome! I'm joining now!  big_smile
edit: Is it online?  tongue

Last edited by slinger (2012-04-29 13:27:55)


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

Offline

 

#3 2012-04-29 16:16:41

rookwood101
Scratcher
Registered: 2011-07-29
Posts: 500+

Re: DragonThunder - A REAL MMO - Releasing today

I think you should tell people that it's the mirror.exe that they have to open.

And yes I think it's offline  hmm


http://i.imgur.com/zeIZW.png

Offline

 

#4 2012-04-29 16:45:18

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

Re: DragonThunder - A REAL MMO - Releasing today

Yeah, sorry. I just realized the server crashed...
(btw, I saw slinger connect, login, and move around)


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

Offline

 

#5 2012-04-29 16:48:41

Borrego6165
Scratcher
Registered: 2011-03-10
Posts: 1000+

Re: DragonThunder - A REAL MMO - Releasing today

adding to april 29th


Generation:4001 Build a beautiful city, with over 50 objects and over 10000 tiles per city! This simulates traffic, pollution, tourism, crime and more!

Offline

 

#6 2012-04-29 16:52:38

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

Re: DragonThunder - A REAL MMO - Releasing today

Borrego6165 wrote:

adding to april 29th

Thanks.


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

Offline

 

#7 2012-04-30 10:31:32

GeonoTRON2000
Scratcher
Registered: 2009-12-24
Posts: 1000+

Re: DragonThunder - A REAL MMO - Releasing today

Is the server down?
When I try to login, the mirror just crashes!

Last edited by GeonoTRON2000 (2012-04-30 10:31:50)


http://i.imgur.com/BAEgGDL.png

Offline

 

#8 2012-04-30 19:44:11

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

Re: DragonThunder - A REAL MMO - Releasing today

Yeah, it was offline.


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

Offline

 

#9 2012-05-14 17:16:06

pookawee
New Scratcher
Registered: 2010-10-17
Posts: 3

Re: DragonThunder - A REAL MMO - Releasing today

BOBBYBEE! I need help. I am currently making my own mmo, but I need to know how to put it online-multiplayer. Can you notify me of how?

btw, how do you go from new scratcher to scratcher? I am really experienced, but I don't have many projects posted. Don't judge me by those projects!

Offline

 

#10 2012-05-16 16:07:14

pookawee
New Scratcher
Registered: 2010-10-17
Posts: 3

Re: DragonThunder - A REAL MMO - Releasing today

;(  smile   sad

Offline

 

#11 2012-05-16 16:16:26

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

Re: DragonThunder - A REAL MMO - Releasing today

It's kind of hard to explain...


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

Offline

 

#12 2012-05-17 12:41:40

Andres-Vander
Scratcher
Registered: 2010-09-16
Posts: 1000+

Re: DragonThunder - A REAL MMO - Releasing today

Does it work?


http://www.gifsoup.com/view1/2260823/flugelhorn-feline-o.gif

Offline

 

Board footer