RegionGenerator

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(New page: Heres a Region Generator in Python It generates a square piece of land. It requires the cheetah templating module and python 2.5 [CODE]#!/usr/bin/python from Cheetah.Template import Tem...)
 
Line 5: Line 5:
 
It requires the cheetah templating module and python 2.5
 
It requires the cheetah templating module and python 2.5
  
[CODE]#!/usr/bin/python
+
[PRE]#!/usr/bin/python
 
from Cheetah.Template import Template
 
from Cheetah.Template import Template
 
import uuid
 
import uuid
Line 64: Line 64:
 
         tmplfile = open(path, 'w')
 
         tmplfile = open(path, 'w')
 
         tmplfile.write(maketemplate(regionname, xnum, ynum, s['startport'] + (counter - 1)))
 
         tmplfile.write(maketemplate(regionname, xnum, ynum, s['startport'] + (counter - 1)))
         tmplfile.close()[/CODE]
+
         tmplfile.close()[/PRE]

Revision as of 15:35, 12 July 2008

Heres a Region Generator in Python

It generates a square piece of land.

It requires the cheetah templating module and python 2.5

[PRE]#!/usr/bin/python from Cheetah.Template import Template import uuid import os

  1. START OF CONFIGURATION

s = {}

  1. Region Configuration

s['regionname'] = "RichieWorld" # Type the name of your island s['x'] = [2900,3000] # From - To x position s['y'] = [2900,3000] # From - To y position

  1. User Configuration

s['firstname'] = "Richie" # Account firstname s['lastname'] = "Ward" # Account lastname s['useruuid'] = 'your clients uuid goes here' s['password'] = 'rewrich' # Account password

  1. Network Configuration

s['startport'] = 9000 # Port the regions start on

                                   # incrimented by 1 each time

s['internalip'] = "87.98.249.170" # Server ip s['externalhost'] = "4rensics.org" # Domain name or ip of server

                                   # (accessed externally)
  1. ------------------------------

regionsdir = 'Regions' # Files created in this directory, created if not found.

  1. Template

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" /> </Root>"""

  1. END OF CONFIGURATION

def maketemplate(regionname,x,y,port):

   t = Template(template)
   t.s = s
   t.uuid = str(uuid.uuid1())
   t.regionname = regionname
   t.x = x
   t.y = y
   t.port = port
   return str(t)

try:

   os.mkdir(regionsdir)

except OSError:

   pass

counter = 0 for xnum in range(s['x'][0], s['x'][1]):

   for ynum in range(s['y'][0], s['y'][1]):
       counter += 1
       
       if counter == 1:
           regionname = s['regionname']
       else:
           regionname = s['regionname'] + str(counter)
       
       path = os.path.join(regionsdir,"%s.%s.%s.xml" % (regionname, xnum, ynum))
       tmplfile = open(path, 'w')
       tmplfile.write(maketemplate(regionname, xnum, ynum, s['startport'] + (counter - 1)))
       tmplfile.close()[/PRE]
Personal tools
General
About This Wiki