RegionGenerator

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(How to use)
(Source Code)
Line 30: Line 30:
 
You can get python from http://www.python.org/download/
 
You can get python from http://www.python.org/download/
  
<pre>#!/usr/bin/python
+
==== regiongen.py ====
 +
<pre>
 +
#!/usr/bin/python
 +
# REGIONGEN 2.00 BY RICHIE WARD
 
from Cheetah.Template import Template
 
from Cheetah.Template import Template
 
import uuid
 
import uuid
 
import os
 
import os
 
import pickle
 
import pickle
 +
import regionconfig
  
# ----------------------
 
# START OF CONFIGURATION
 
s = {}
 
 
# Region Configuration
 
s['regionname'] = "LandsNameHere"    # Type the name of your land
 
s['x'] = [2900,3000]                # From - To x position
 
s['y'] = [2900,3000]                # From - To y position
 
 
 
# User Configuration
 
s['firstname'] = "John"          # Account firstname
 
s['lastname'] = "Doe"              # Account lastname
 
s['useruuid'] = 'your clients uuid goes here'
 
s['password'] = 'mypass'          # Account password
 
 
 
# Network Configuration
 
s['startport'] = 9000              # Port the regions start on
 
                                    # incrimented by 1 each time
 
s['internalip'] = "123.456.789.123"  # Server ip
 
s['externalhost'] = "mydomain.org"  # Domain name or ip of server
 
                                    # (accessed externally)
 
 
# Files are put in here.
 
 
regionsdir = 'Regions'
 
regionsdir = 'Regions'
  
 
template = """<Root>
 
template = """<Root>
<Config sim_UUID="$uuid" sim_name="$regionname" sim_location_x="$x" sim_location_y="$y" internal_ip_address="$s.internalip" internal_ip_port="$port" allow_alternate_ports="false" external_host_name="$s.externalhost" master_avatar_uuid="$s.useruuid" estate_covenant_uuid="00000000-0000-0000-0000-000000000000" master_avatar_first="$s.firstname" master_avatar_last="$s.lastname" master_avatar_pass="$s.password" />
+
<Config sim_UUID="$uuid" sim_name="$regionname" sim_location_x="$x" sim_location_y="$y" internal_ip_address="$s.internalip" internal_ip_port="$port" allow_alternate_ports="false" external_host_name="$s.externalhost" master_avatar_uuid="$s.useruuid" estate_covenant_uuid="00000000-0000-0000-0000-000000000000" lastmap_refresh="0" master_avatar_first="$s.firstname" master_avatar_last="$s.lastname" $password />
</Root>"""
+
</Root>
 +
 
 +
"""
  
 
savefile = "regiongen_save.pkl"
 
savefile = "regiongen_save.pkl"
# END OF CONFIGURATION
 
# --------------------
 
  
def maketemplate(regionname, x, y, port, uid):
+
def maketemplate(regionname, x, y, port, uid, password=None):
 
     t = Template(template)
 
     t = Template(template)
 
     t.s = s
 
     t.s = s
 
     t.uuid = uid
 
     t.uuid = uid
 +
    t.password = password
 
     t.regionname = regionname
 
     t.regionname = regionname
 
     t.x = x
 
     t.x = x
Line 96: Line 76:
 
except IOError:
 
except IOError:
 
     pass
 
     pass
 
+
   
counter = 0
+
for s in regionconfig.configlist:
for xnum in range(s['x'][0], s['x'][1]):
+
    print s
    for ynum in range(s['y'][0], s['y'][1]):
+
    counter = 0
        counter += 1
+
    for xnum in range(s['x'][0], s['x'][1]):
        default = False
+
        for ynum in range(s['y'][0], s['y'][1]):
       
+
            counter += 1
        # Figure out region name
+
            default = False
        if counter == 1:
+
           
            default = True
+
            # Figure out region name
            regionname = s['regionname']
+
            if counter == 1:
        else:
+
                default = True
            regionname = s['regionname'] + str(counter)
+
                regionname = s['regionname']
       
+
            else:
        # Figure out paths
+
                regionname = s['regionname'] + str(counter)
        if default:
+
               
            path = os.path.join(regionsdir,"default.xml")
+
            # Figure out password
        else:
+
            if s.has_key('password'):
 +
                password = "master_avatar_pass=\"%s\"" % s['password']
 +
            else:
 +
                password = ''
 +
               
 +
            # Figure out paths
 
             path = os.path.join(regionsdir,"%s.%s.%s.xml" % \
 
             path = os.path.join(regionsdir,"%s.%s.%s.xml" % \
                    (regionname, xnum, ynum))
+
                        (regionname, xnum, ynum))
       
+
           
        # Calculate port
+
            # Calculate port
        port = s['startport'] + (counter - 1)
+
            port = s['startport'] + (counter - 1)
        # Try to get UUID from settings
+
           
        # Generate + Save if not found
+
            # Try to get UUID from settings
        if settings.has_key(regionname):
+
            # Generate + Save if not found
            uid = settings[regionname]
+
            if settings.has_key(regionname):
        else:
+
                uid = settings[regionname]
            uid = str(uuid.uuid1())
+
            else:
            settings[regionname] = uid
+
                uid = str(uuid.uuid1())
        # Make template
+
                settings[regionname] = uid
        tmpldata = maketemplate(regionname, xnum, ynum, port, uid)
+
               
       
+
            # Make template
        # Save file
+
            tmpldata = maketemplate(regionname, xnum, ynum, port, uid, password)
        tmplfile = open(path, 'w')
+
           
        tmplfile.write(tmpldata)
+
            # Save file
        tmplfile.close()
+
            tmplfile = open(path, 'w')
       
+
            tmplfile.write(tmpldata)
        # Print progress
+
            tmplfile.close()
        print regionname
+
           
 +
            # Print progress
 +
            print regionname
  
 
# Save settings file
 
# Save settings file
Line 144: Line 131:
 
except IOError:
 
except IOError:
 
     pass
 
     pass
 +
</pre>
 +
 +
==== regionconfig.py ====
 +
<pre>
 +
# REGIONGEN 2.00 CONFIGURATION FILE
 +
configlist = [] # Dont touch this
 +
 +
# START OF REGION
 +
s = {}                          # Dont touch this
 +
# Region Configuration
 +
s['regionname'] = "RegionSetOne" # Type the name of your island
 +
s['x'] = [5100,5105]            # X Position... From <------> To
 +
s['y'] = [5100,5105]            # Y Position... From <------> To
 +
 +
# User Configuration
 +
s['firstname'] = "Tom"  # Your First Name
 +
s['lastname'] = "Jones"      # Your Last Name
 +
s['useruuid'] = 'get your clients uuid'  # Your UUID, You can use a script in game to get this
 +
#s['password'] = 'pass'    # This is optional, it is commented out by default.
 +
 +
# Network Configuration
 +
s['startport'] = 9000              # We recommend leaving this at 9000 for opensim
 +
                                    # unless this isnt the first region.
 +
s['internalip'] = "123.123.123.123"  # You need to get this to a internal wired/wireless lan ip address
 +
s['externalhost'] = "example.org"  # This is the address that people connect from the outside world to
 +
configlist.append(s)                # Dont touch this
 +
# END OF REGION
 +
# YOU MAY COPY AND PASTE MORE CONFIGURATIONS INTO THIS FILE TO ADD MORE REGIONS.
 +
 +
 +
# START OF REGION
 +
s = {}                          # Dont touch this
 +
# Region Configuration
 +
s['regionname'] = "RegionSetTwo" # Type the name of your island
 +
s['x'] = [5200,5205]            # X Position... From <------> To
 +
s['y'] = [5200,5205]            # Y Position... From <------> To
 +
 +
# User Configuration
 +
s['firstname'] = "Tom"  # Your First Name
 +
s['lastname'] = "Jones"      # Your Last Name
 +
s['useruuid'] = 'get your clients uuid'  # Your UUID, You can use a script in game to get this
 +
#s['password'] = 'pass'    # This is optional, it is commented out by default.
 +
 +
# Network Configuration
 +
s['startport'] = 9100              # We recommend leaving this at 9000 for opensim
 +
                                    # unless this isnt the first region.
 +
s['internalip'] = "123.123.123.123"  # You need to get this to a internal wired/wireless lan ip address
 +
s['externalhost'] = "example.org"  # This is the address that people connect from the outside world to
 +
configlist.append(s)                # Dont touch this
 +
# END OF REGION
 +
# YOU MAY COPY AND PASTE MORE CONFIGURATIONS INTO THIS FILE TO ADD MORE REGIONS.
 
</pre>
 
</pre>

Revision as of 16:51, 14 July 2008

Contents

Region Generator

About

It generates a square piece of land.

You can feed it the from-to X Postion and from-to Y position then it makes the xml files for you.

Download

I have made a .exe version of this program for windows, you can get it from these locations:

http://www.mediafire.com/?xred9vm0ent

http://4rensics.com/regiongen.zip

How to use

If using windows version

  • Extract to somewhere on your computer, i.e. The desktop.
  • Edit the regionconfig.py file.
  • Run regiongen.exe
  • Copy the Regions folder to your opensim/bin folder.
  • If you run it again, it will update the regions but it will not delete the files. If you made a big screw up, delete the Regions folder.

If using the python source code (Linux, mac etc), make sure you have the cheetah and python 2.5 dependency's installed and edit the configuration in the header, then run :)

Source Code

It requires the Cheetah Templating module and python 2.5.

You can get cheetah from http://www.cheetahtemplate.org/

You can get python from http://www.python.org/download/

regiongen.py

#!/usr/bin/python
# REGIONGEN 2.00 BY RICHIE WARD
from Cheetah.Template import Template
import uuid
import os
import pickle
import regionconfig

regionsdir = 'Regions'

template = """<Root>
<Config sim_UUID="$uuid" sim_name="$regionname" sim_location_x="$x" sim_location_y="$y" internal_ip_address="$s.internalip" internal_ip_port="$port" allow_alternate_ports="false" external_host_name="$s.externalhost" master_avatar_uuid="$s.useruuid" estate_covenant_uuid="00000000-0000-0000-0000-000000000000" lastmap_refresh="0" master_avatar_first="$s.firstname" master_avatar_last="$s.lastname" $password />
</Root>

"""

savefile = "regiongen_save.pkl"

def maketemplate(regionname, x, y, port, uid, password=None):
    t = Template(template)
    t.s = s
    t.uuid = uid
    t.password = password
    t.regionname = regionname
    t.x = x
    t.y = y
    t.port = port
    return str(t)

# Make directory to put regions in if not there
try:
    os.mkdir(regionsdir)
except OSError:
    pass

settings = {}

# Load settings file
try:
    settingsfile = open(savefile)
    settings = pickle.load(settingsfile)
    settingsfile.close()
except IOError:
    pass
    
for s in regionconfig.configlist:
    print s
    counter = 0
    for xnum in range(s['x'][0], s['x'][1]):
        for ynum in range(s['y'][0], s['y'][1]):
            counter += 1
            default = False
            
            # Figure out region name
            if counter == 1:
                default = True
                regionname = s['regionname']
            else:
                regionname = s['regionname'] + str(counter)
                
            # Figure out password
            if s.has_key('password'):
                password = "master_avatar_pass=\"%s\"" % s['password']
            else:
                password = ''
                
            # Figure out paths
            path = os.path.join(regionsdir,"%s.%s.%s.xml" % \
                        (regionname, xnum, ynum))
            
            # Calculate port
            port = s['startport'] + (counter - 1)
            
            # Try to get UUID from settings
            # Generate + Save if not found
            if settings.has_key(regionname):
                uid = settings[regionname]
            else:
                uid = str(uuid.uuid1())
                settings[regionname] = uid
                
            # Make template
            tmpldata = maketemplate(regionname, xnum, ynum, port, uid, password)
            
            # Save file
            tmplfile = open(path, 'w')
            tmplfile.write(tmpldata)
            tmplfile.close()
            
            # Print progress
            print regionname

# Save settings file
try:
    settingsfile = open(savefile, 'w')
    pickle.dump(settings, settingsfile)
    settingsfile.close()
except IOError:
    pass

regionconfig.py

# REGIONGEN 2.00 CONFIGURATION FILE
configlist = [] # Dont touch this

# START OF REGION
s = {}                          # Dont touch this
# Region Configuration
s['regionname'] = "RegionSetOne" # Type the name of your island
s['x'] = [5100,5105]            # X Position... From <------> To
s['y'] = [5100,5105]            # Y Position... From <------> To

# User Configuration
s['firstname'] = "Tom"   # Your First Name
s['lastname'] = "Jones"      # Your Last Name
s['useruuid'] = 'get your clients uuid'  # Your UUID, You can use a script in game to get this
#s['password'] = 'pass'     # This is optional, it is commented out by default.

# Network Configuration
s['startport'] = 9000               # We recommend leaving this at 9000 for opensim
                                    # unless this isnt the first region.
s['internalip'] = "123.123.123.123"   # You need to get this to a internal wired/wireless lan ip address
s['externalhost'] = "example.org"  # This is the address that people connect from the outside world to
configlist.append(s)                # Dont touch this
# END OF REGION
# YOU MAY COPY AND PASTE MORE CONFIGURATIONS INTO THIS FILE TO ADD MORE REGIONS.


# START OF REGION
s = {}                          # Dont touch this
# Region Configuration
s['regionname'] = "RegionSetTwo" # Type the name of your island
s['x'] = [5200,5205]            # X Position... From <------> To
s['y'] = [5200,5205]            # Y Position... From <------> To

# User Configuration
s['firstname'] = "Tom"   # Your First Name
s['lastname'] = "Jones"      # Your Last Name
s['useruuid'] = 'get your clients uuid'  # Your UUID, You can use a script in game to get this
#s['password'] = 'pass'     # This is optional, it is commented out by default.

# Network Configuration
s['startport'] = 9100               # We recommend leaving this at 9000 for opensim
                                    # unless this isnt the first region.
s['internalip'] = "123.123.123.123"   # You need to get this to a internal wired/wireless lan ip address
s['externalhost'] = "example.org"  # This is the address that people connect from the outside world to
configlist.append(s)                # Dont touch this
# END OF REGION
# YOU MAY COPY AND PASTE MORE CONFIGURATIONS INTO THIS FILE TO ADD MORE REGIONS.
Personal tools
General
About This Wiki