Пример #1
0
    def insert_objects(self):
        '''Insert any objects you want to be present in the zone into the
        database in this call.

        This gets called exactly once per database. If you change something here
        and want it to appear in the zone's database, you will need to clear the
        database first.

        Deleting the "Loading Complete" object will only cause duplicates.
        Do not do this.
        '''

        # Place 100 barrels randomly:
        for i in xrange(100):
            obj = Object()
            obj.name = "Barrel%d" % i
            obj.resource = 'barrel'
            obj.loc = IntVector(x=randloc(), y=randloc(), z=randloc())
            obj.rot = FloatVector(x=randrot(), y=randrot(), z=randrot())
            obj.scale = FloatVector(x=randscale(), y=randscale(), z=randscale())
            obj.vel = FloatVector(x=0, y=0, z=0)
            obj.states.extend(['closed', 'whole', 'clickable'])
            obj.save()

        # Place 10 chickens randomly:
        for i in xrange(10):
            obj = ScriptedObject()
            obj.name = "Chicken #%d" % i
            obj.resource = 'chicken'
            obj.loc = IntVector(x=randloc(), y=randloc(), z=randloc())
            obj.rot = FloatVector(x=randrot(), y=randrot(), z=randrot())
            obj.scale = FloatVector(x=randscale(), y=randscale(), z=randscale())
            obj.vel = FloatVector(x=0, y=0, z=0)
            obj.states.extend(['alive', 'whole', 'clickable'])
            obj.scripts = ['games.objects.chicken']
            obj.save()

        print [o.name for o in Object.objects()]