class World(Factory): protocol = WorldProtocol def __init__(self, base_path): assert os.path.isdir(base_path) self.base_path = base_path self.config_path = os.path.join(self.base_path, "world.conf") self.load_config() def load_config(self): self.config = ConfigParser() self.config.read(self.config_path) self.size = [ self.config.getint("size", "x"), self.config.getint("size", "y"), self.config.getint("size", "z"), ] self.spawn = [ self.config.getint("spawn", "x"), self.config.getint("spawn", "y"), self.config.getint("spawn", "z"), ] def start(self): logging.info("Starting world '%s'" % self.base_path) self.engine = BlockEngine(self.base_path, self.size[0], self.size[1], self.size[2]) self.engine.start_mmap() def stop(self): logging.info("Stopping world '%s'" % self.base_path) self.engine.stop_mmap() del self.engine def listen(self): # Makes us listen on our configured port. reactor.listenTCP(self.config.getint("network", "port"), self)
def start(self): logging.info("Starting world '%s'" % self.base_path) self.engine = BlockEngine(self.base_path, self.size[0], self.size[1], self.size[2]) self.engine.start_mmap()
os.mkdir(base_path) # Calculate some locations x = int(options['x']) y = int(options['y']) z = int(options['z']) options['sp_x'] = x // 2 options['sp_y'] = y options['sp_z'] = z // 2 # Make the configuration file cfh = open(os.path.join(base_path, "world.conf"), "w") cfh.write(""" [network] port = %(p)s [size] x = %(x)s y = %(y)s z = %(z)s [spawn] x = %(sp_x)s y = %(sp_y)s z = %(sp_z)s """ % options) # Alright, make a world. from myne2.world.blockengine import BlockEngine BlockEngine.create(base_path, x, y, z, ["\0"]*y)