예제 #1
0
def main():
    OPTIONS, argv = getOptions('mmolite/config/servers.cfg', 'world server',
                               sys.argv)

    if OPTIONS.username == "-": OPTIONS.username = raw_input("Username: "******"-": OPTIONS.password = raw_input("Password: "******"Setting up World Server..."

        dbconn.resetDB()
        print "Successfully"
        return
    else:
        print "Initialize World Server database..."
        dbconn.startDB()
        Clients.dropTable(ifExists=True)
        Clients.createTable()

        print "Run TGE dedicated server"
        argv.extend([
            '-dedicated', '-game', 'test.mmo', '-mission',
            'test.mmo/data/missions/chatspot.mis'
        ])
        pytorque.initialize(len(argv), argv)

        print "World server connecting to master server: ip[%s] port[%d]" % (
            OPTIONS.master_ip, OPTIONS.master_port)

        creds = credentials.UsernamePassword(OPTIONS.username,
                                             OPTIONS.password)
        world = WorldServer(OPTIONS.master_ip, OPTIONS.master_port,
                            OPTIONS.world_port, PeerType.World, creds,
                            WorldPortal())
        world.run()
        #reactor.run()
        reactor.startRunning()

        #the main loop is broken out and can be combined with other frameworks rather easily
        while pytorque.tick():
            reactorTick()

        #cleanup pytorque.. goodbye!
        pytorque.shutdown()
예제 #2
0
def main():
    global clientObj
    global userObj
    Running = False
    OPTIONS, argv = getOptions('mmolite/config/client.cfg', 'client', sys.argv)

    print "MMO test client initializing torque client"
    if '-game' not in argv:
        argv.extend(['-game', 'test.mmo'])
    pytorque.initialize(len(argv), argv)

    print "MMO test client connecting to: ip[%s] port[%d]" % (
        OPTIONS.master_ip, OPTIONS.master_port)
    clientObj = PbAuthClient()
    clientObj.login("Client", "tneilc", OPTIONS.master_ip, OPTIONS.master_port)
    userObj = PbAuthUser()

    # get torque object
    loginButton = TorqueObject("LoginButton")
    signupButton = TorqueObject("SignupButton")
    # set torque object's attribute
    loginButton.Command = 'LoginButton.OnButton("%s", %s);' % (
        OPTIONS.master_ip, OPTIONS.master_port)
    signupButton.Command = 'SignupButton.OnButton("%s", %s);' % (
        OPTIONS.master_ip, OPTIONS.master_port)
    # map python function to torque action
    pytorque.export(OnLoginPressed, "LoginButton", "OnButton",
                    "Login button command", 2, 2)
    pytorque.export(OnSignupPressed, "SignupButton", "OnButton",
                    "Signup button command", 2, 2)
    # call torque object method
    loginButton.setActive(0)
    signupButton.setActive(0)

    print "MMO test client running"
    reactor.startRunning()

    #the main loop is broken out and can be combined with other frameworks rather easily
    while pytorque.tick():
        reactorTick()

    #cleanup pytorque.. goodbye!
    pytorque.shutdown()

    print "MMO test client quit"
예제 #3
0
def main():
    global clientObj
    global userObj
    Running = False
    OPTIONS, argv = getOptions('mmolite/config/client.cfg', 'client', sys.argv)

    print "MMO test client initializing torque client"
    if '-game' not in argv:
        argv.extend(['-game', 'test.mmo'])
    pytorque.initialize(len(argv),argv)
    
    print "MMO test client connecting to: ip[%s] port[%d]"%(OPTIONS.master_ip, OPTIONS.master_port)
    clientObj = PbAuthClient()
    clientObj.login("Client", "tneilc", OPTIONS.master_ip, OPTIONS.master_port)
    userObj = PbAuthUser()
    
    # get torque object
    loginButton = TorqueObject("LoginButton")
    signupButton = TorqueObject("SignupButton")
    # set torque object's attribute
    loginButton.Command = 'LoginButton.OnButton("%s", %s);'%(OPTIONS.master_ip, OPTIONS.master_port)
    signupButton.Command = 'SignupButton.OnButton("%s", %s);'%(OPTIONS.master_ip, OPTIONS.master_port)
    # map python function to torque action
    pytorque.export(OnLoginPressed,"LoginButton","OnButton","Login button command",2,2)
    pytorque.export(OnSignupPressed,"SignupButton","OnButton","Signup button command",2,2)
    # call torque object method
    loginButton.setActive(0)
    signupButton.setActive(0)
    
    print "MMO test client running"
    reactor.startRunning()

    #the main loop is broken out and can be combined with other frameworks rather easily
    while pytorque.tick():
        reactorTick()

    #cleanup pytorque.. goodbye!
    pytorque.shutdown()
    
    print "MMO test client quit"
예제 #4
0
def main():
    OPTIONS, argv = getOptions('mmolite/config/servers.cfg', 'world server', sys.argv)
    
    if OPTIONS.username=="-": OPTIONS.username = raw_input("Username: "******"-": OPTIONS.password = raw_input("Password: "******"Setting up World Server..."
        
        dbconn.resetDB()
        print "Successfully"
        return
    else: 
        print "Initialize World Server database..."
        dbconn.startDB()
        Clients.dropTable(ifExists=True); Clients.createTable()
        
        print "Run TGE dedicated server"
        argv.extend(['-dedicated', '-game', 'test.mmo', '-mission', 'test.mmo/data/missions/chatspot.mis'])
        pytorque.initialize(len(argv),argv)

        print "World server connecting to master server: ip[%s] port[%d]"%(OPTIONS.master_ip, OPTIONS.master_port)
        
        creds = credentials.UsernamePassword(OPTIONS.username, OPTIONS.password)
        world = WorldServer(OPTIONS.master_ip, OPTIONS.master_port, OPTIONS.world_port, PeerType.World, creds, WorldPortal())
        world.run()
        #reactor.run()
        reactor.startRunning()

        #the main loop is broken out and can be combined with other frameworks rather easily
        while pytorque.tick():
            reactorTick()

        #cleanup pytorque.. goodbye!
        pytorque.shutdown()
예제 #5
0
# MMO Lite 2007
# MMOLite test Python Torque Integration

#Torque as a standard Python extension (no longer a executable)

#register "current working folder as system path"
#there is probably a better way of doing this (change from Python 2.4->2.5)
import sys, os
sys.path.append(os.getcwd())

from mmolite import pytorque
from mmolite.pytorque import TorqueObject

#initialize pytorque, this also executes main.cs and the .cs packages
pytorque.initialize(len(sys.argv),sys.argv)

#example of executing a script file
#f = file("myscript.cs","rb")
#script = f.read()
#f.close()
#pytorque.evaluate(script)

#or, just generate the cs code right inside Python!

pytorque.evaluate("""
new GuiBitmapButtonCtrl(MyButton) {
 profile = "GuiButtonProfile";
 horizSizing = "right";
 vertSizing = "bottom";
 position = "404 361";
 extent = "285 85";