Example #1
0
    def pre_build_hook(self, player, builddata):
        item, metadata, x, y, z, face = builddata

        if item.slot != items["paintings"].slot:
            return True, builddata, False

        if face in ["+y", "-y"]:
            # No paintings on the floor.
            return False, builddata, False

        # Make sure we can remove it from the inventory.
        if not player.inventory.consume((item.slot, 0), player.equipped):
            return False, builddata, False

        entity = factory.create_entity(x,
                                       y,
                                       z,
                                       "Painting",
                                       direction=face_to_direction[face],
                                       motive=random.choice(painting_names))
        factory.broadcast(entity.save_to_packet())

        # Force the chunk (with its entities) to be saved to disk.
        factory.world.mark_dirty((x, y, z))

        return False, builddata, False
Example #2
0
File: debug.py Project: JDShu/bravo
    def chat_command(self, username, parameters):
        make = True
        position = factory.protocols[username].location
        if len(parameters) == 1:
            mob = parameters[0]
            number = 1
        elif len(parameters) == 2:
            mob = parameters[0]
            number = int(parameters[1])
        else:
            make = False
            return ("Couldn't understand you!",)
        if make:
#            try:
            for i in range(0,number):
                print mob, number
                entity = factory.create_entity(position.x,position.y,position.z,mob)
                factory.broadcast(entity.save_to_packet())
                factory.world.mob_manager.start_mob(entity)
            return ("Made mob!",)
Example #3
0
File: debug.py Project: JDShu/bravo
 def chat_command(self, username, parameters):
     make = True
     position = factory.protocols[username].location
     if len(parameters) == 1:
         mob = parameters[0]
         number = 1
     elif len(parameters) == 2:
         mob = parameters[0]
         number = int(parameters[1])
     else:
         make = False
         return ("Couldn't understand you!", )
     if make:
         #            try:
         for i in range(0, number):
             print mob, number
             entity = factory.create_entity(position.x, position.y,
                                            position.z, mob)
             factory.broadcast(entity.save_to_packet())
             factory.world.mob_manager.start_mob(entity)
         return ("Made mob!", )
Example #4
0
    def pre_build_hook(self, player, builddata):
        item, metadata, x, y, z, face = builddata

        if item.slot != items["paintings"].slot:
            return True, builddata, False

        if face in ["+y", "-y"]:
            # No paintings on the floor.
            return False, builddata, False

        # Make sure we can remove it from the inventory.
        if not player.inventory.consume((item.slot, 0), player.equipped):
            return False, builddata, False

        entity = factory.create_entity(x, y, z, "Painting",
            direction=face_to_direction[face],
            motive=random.choice(painting_names))
        factory.broadcast(entity.save_to_packet())

        # Force the chunk (with its entities) to be saved to disk.
        factory.world.mark_dirty((x, y, z))

        return False, builddata, False